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
70
最高にモノづくりを楽しめる組織を目指して
mserizawa
5
2.1k
SmartHR における Authlete の活用
mserizawa
0
1.6k
SmartHR の開発現場最新事情 〜マイクロサービス始めました〜
mserizawa
5
3.4k
API Study #10
mserizawa
0
560
API Meetup #15
mserizawa
0
250
Featured
See All Featured
Building an army of robots
kneath
302
42k
Happy Clients
brianwarren
97
6.7k
KATA
mclloyd
27
13k
Optimising Largest Contentful Paint
csswizardry
31
2.8k
Testing 201, or: Great Expectations
jmmastey
38
7k
Building Applications with DynamoDB
mza
90
6k
A Modern Web Designer's Workflow
chriscoyier
692
190k
Documentation Writing (for coders)
carmenintech
65
4.3k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
663
120k
Speed Design
sergeychernyshev
22
480
Six Lessons from altMBA
skipperchong
26
3.4k
BBQ
matthewcrist
85
9.2k
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͍ͨ͠