Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
API Study #4
Search
Masato SERIZAWA
January 24, 2017
3
850
API Study #4
RESTful な API におけるファイルアップロードについて
Masato SERIZAWA
January 24, 2017
Tweet
Share
More Decks by Masato SERIZAWA
See All by Masato SERIZAWA
クラウド人事労務ソフトウェア開発の勘所
mserizawa
0
76
最高にモノづくりを楽しめる組織を目指して
mserizawa
5
2.1k
SmartHR における Authlete の活用
mserizawa
0
1.7k
SmartHR の開発現場最新事情 〜マイクロサービス始めました〜
mserizawa
5
3.4k
API Study #10
mserizawa
0
570
API Meetup #15
mserizawa
0
250
Featured
See All Featured
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
31
2.7k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
How STYLIGHT went responsive
nonsquared
95
5.2k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Producing Creativity
orderedlist
PRO
341
39k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
Agile that works and the tools we love
rasmusluckow
327
21k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Docker and Python
trallard
40
3.1k
Transcript
3&45GVMͳ"1*ʹ͓͚Δ ϑΝΠϧΞοϓϩʔυʹ͍ͭͯ ۔ᖒխਓ 5VFT CONFIDENCIAL SmartHR Engineer API Study #4
CONFIDENCIAL ۔ᖒ խਓ @masato_serizawa • גࣜձࣾ KUFU ΤϯδχΞ ͰɺSmartHR ͱ͍͏αʔϏεΛ։
ൃ͍ͯ͠·͢ • ΤϯδχΞͱͯ͠ͷΩϟϦΞͷ΄ͱΜͲΛ WebAPI ͷઃܭɾ ։ൃɾӡ༻ɾൢചΛͯ͠ա͍ͯ͝͠·͢ • ͨ·ʹ Hackathon ʹग़ͨΓ͠·͢ • झຯ Data Visualization Ͱ͢
ຊ͓͢Δ͜ͱ ʰ3&45GVM"1*ʹ͓͚ΔϑΝΠϧΞοϓϩʔυʱ
CONFIDENCIAL WebAPI Λ։ൃ͍ͯ͠ΔͱɺϑΝΠϧΛѻ͍͍ͨ ໘ʹग़͘Θ͢͜ͱ͋Δͱࢥ͍·͢ɻ ͨͩɺ͍͟ REST ͷ֓೦ʹϑΝΠϧͷೖग़ྗΛ ͯࠐ͏ͱ͢Δͱɺ͍·͍ͪͬ͘͠Γͤ͞ΒΕͣɺ Ή͜ͱʹͳΔͷͰͳ͍Ͱ͠ΐ͏͔ɻ ࠓճ࣮αʔϏεͷྫΛ౿·͑ͭͭɺϕετϓϥ
ΫςΟεΛ୳ٻ͍ͯ͜͠͏ͱࢥ͍·͢ɻ
ϑΝΠϧͷૹ৴ํ๏
CONFIDENCIAL •RFC2388 Ͱఆٛ͞Ε͍ͯΔ HTTP ʹ͓͚ΔϑΝΠ ϧૹ৴ͷԦಓ •HTML ϑΥʔϜ͔ΒϑΝΠϧΛૹ৴͢ΔͨΊͷن ֨ͰɺϑΝΠϧσʔλҎ֎ʹ༷ʑͳσʔλΛ ਵͤ͞ΒΕΔ
•όΠφϦΛѻ͑ΔϝϦοτ͕͋Δ໘ɺJSON ϕʔ εͷ API ͱͷੑ͍ NVMUJQBSUGPSNEBUB
CONFIDENCIAL NVMUJQBSUGPSNEBUB 9O+-F;*CC(6:U[12+V $POUFOU%JTQPTJUJPOGPSNEBUBOBNFUJUMF UJUMF 9O+-F;*CC(6:U[12+V $POUFOU%JTQPTJUJPOGPSNEBUBOBNFEFTDSJQUJPO EFTDSJQUJPO 9O+-F;*CC(6:U[12+V $POUFOU%JTQPTJUJPOGPSNEBUBOBNFTUSFBN@JE
9O+-F;*CC(6:U[12+V $POUFOU%JTQPTJUJPOGPSNEBUBOBNFJUFN@JNBHFT<>pMFOBNFTBNQMFQOH $POUFOU5ZQFJNBHFQOH $POUFOU-FOHUI \1VUCJOBSZDPOUFOUTUIBUZPVXBOUUPVQMPBE^ UBC"1*ͷαϯϓϧΑΓҾ༻
CONFIDENCIAL •ϑΝΠϧσʔλΛ Base64 ΤϯίʔυͰจࣈྻԽ ͯ͠ѻ͏ •ಛʹ RFC Ͱఆٛ͞Ε͍ͯΔͷͰͳ͍͕ɺେख Web αʔϏεͷ
API Ͱͷ࠾༻࣮͕͋Δ •จࣈྻͳͷͰͦͷ·· JSON ʹ٧ΊΕΔ໘ɺ σʔλ༰ྔ͕͔͞ΜͰ͠·͏σϝϦοτ͕͋Δ #BTF
CONFIDENCIAL \ BTTFU\ LFZFYBNQMFHJG BUUBDINFOU 58'V*(M[*(3QD3QCNEB9/P;82T*(WE$#WCNY*(+*(IQDZ#Z; 8'[CT*(+E$#JF4#B(M[ *)/QCNEC('Z*)# E87L*('V;$#QCN3M;N'B8EI:NYM*(EMCN7Z:93QCHC:HBWE
YM;(EM-$#MF(/M;83[*)3P ;4#[B(ZE$#;8IMC87V:6HC:H:8*(/IDNIC$#XC(7ID 7Z;4 ^ ^ #BTF
ϑΝΠϧͷอଘํ๏
CONFIDENCIAL •ಛఆϦιʔεͷಛఆΞτϦϏϡʔτʹରͯ͠ϑΝ ΠϧσʔλΛૹΔํࣜ •RESTful API Ͱ΄ͱΜͲͷ߹ɺૹ৴͢ΔϑΝ ΠϧσʔλԿ͔͠ΒͷϦιʔεʹඥͮͣ͘ͳ ͷͰɺײతͱ͍͑ײత •ϑΝΠϧΛ͍͔ͭ͘ͷϦιʔεͰ͍·Θ͍ͨ͠ ߹ʹ͍͍ͯͳ͍
Ϧιʔεඥ͚ύλʔϯ
CONFIDENCIAL •ϑΝΠϧΞοϓϩʔυͷΤϯυϙΠϯτΛ࡞Γɺ ͦ͜ʹલͬͯϑΝΠϧΛૹΔํࣜ •Ξοϓϩʔυͨ͠ϑΝΠϧΛ1ͭͷϦιʔεͱͯ͠ ൚༻తʹѻ͍͍ͨ߹ʹ༗ޮ •ଞͷϦιʔεʹඥ͚Δ߹ɺID URLɺύε ͳͲΛͦͷϦιʔεͷΞτϦϏϡʔτʹઃఆ͠ ͢ඞཁ͕͋Δ
൚༻ϑΝΠϧΞοϓϩʔυύλʔϯ
࣮αʔϏεͷྫ
CONFIDENCIAL •Contents API ͱ͍͏൚༻ϑΝΠϧΞοϓϩʔυͷ ΤϯυϙΠϯτ͕͋Δ •͜ΕΛ͏͜ͱͰɺʮίϝϯτΤϦΞʹϑΝΠϧ ΛυϥοάΞϯυυϩοϓͯͦ͠ͷ··ϚʔΫμ ϯʹམͱ͠ࠐΉʯΈ͍ͨͳڍಈΛ࣮ݱ͍ͯ͠Δ ͱࢥΘΕΔ •Base64
ͰσʔλΛૹ৴͢Δ (JU)VC"1* IUUQTEFWFMPQFSHJUIVCDPNWSFQPTDPOUFOUT
CONFIDENCIAL •൚༻ϑΝΠϧΞοϓϩʔυͷΤϯυϙΠϯτ͕͋Δ •Ξοϓϩʔυྃ͢ΔͱʮϑΝΠϧΩʔʯ͕ฦͬͯ ͖ͯɺ͜ΕΛͬͯ֘͢ΔΞτϦϏϡʔτΛߋ৽ ͢Δ •ΞτϦϏϡʔτͱͷͻ͖͕ͳ͍ϑΝΠϧ3 ؒͰফڈ͞ΕΔ •multipart/form-data ͰσʔλΛૹ৴͢Δ $ZCP[V"1*
IUUQTDZCP[VEFW[FOEFTLDPNIDKBBSUJDMFT
CONFIDENCIAL •Ϧιʔεඥ͖ܗࣜͷϑΝΠϧΞοϓϩʔυ •Base64 ͷ΄͔ɺURL-encoded binary ͱ URL ͷܗ ࣜͰσʔλΛૹ৴Մೳ 5VNCMS"1*
•Ϧιʔεඥ͖ܗࣜϑΝΠϧΞοϓϩʔυ •multipart/form-data ͰσʔλΛૹ৴͢Δ UBC"1* IUUQTXXXUVNCMSDPNEPDTFOBQJW IUUQUPODIJEPUHJUIVCJPUBCBQJEPDTBQJJUFNDSFBUF@OFX@JUFNIUNM
·ͱΊ
CONFIDENCIAL •ϑΝΠϧͷૹ৴ํ๏ͱอଘํ๏ʹҎԼͷύλʔ ϯ͕͋Δ •API ͷੑ࣭ϑΝΠϧͷ༻్ʹԠͯ͡ɺ͜ΕΒΛ దʹΈ߹ΘͤΔͷ͕ྑ͍ ૹ৴ NVMUJQBSUGPSNEBUB #BTF อଘ
Ϧιʔεඥ͚ ൚༻ϑΝΠϧΞοϓϩʔυ
ΤϯδχΞืूͯ͠·͢ ࠙ձͰ͓͠·͠ΐ͏ʂCFFST w3VCZPO3BJMT w#͚4BB4 wݹͯ͘ڊେͳ੍Λ)BDL͍ͨ͠