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
860
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.5k
API Study #10
mserizawa
0
580
API Meetup #15
mserizawa
0
260
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
222
9k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
66k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
2
290
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
How to train your dragon (web standard)
notwaldorf
88
5.7k
Building an army of robots
kneath
302
44k
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
191
16k
The Cost Of JavaScript in 2023
addyosmani
45
7k
Into the Great Unknown - MozCon
thekraken
33
1.5k
Designing for humans not robots
tammielis
250
25k
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͍ͨ͠