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
870
API Study #4
RESTful な API におけるファイルアップロードについて
Masato SERIZAWA
January 24, 2017
Tweet
Share
More Decks by Masato SERIZAWA
See All by Masato SERIZAWA
クラウド人事労務ソフトウェア開発の勘所
mserizawa
0
78
最高にモノづくりを楽しめる組織を目指して
mserizawa
5
2.1k
SmartHR における Authlete の活用
mserizawa
0
1.7k
SmartHR の開発現場最新事情 〜マイクロサービス始めました〜
mserizawa
5
3.5k
API Study #10
mserizawa
0
580
API Meetup #15
mserizawa
0
260
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
3
350
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.4k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
How to Think Like a Performance Engineer
csswizardry
22
1.3k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
27
1.5k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
240
Being A Developer After 40
akosma
89
590k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Unsuck your backbone
ammeep
669
57k
GitHub's CSS Performance
jonrohan
1030
460k
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͍ͨ͠