rest - RESTful HTTP API design pattern for specifying file pairs? -
i attempting design http api whereby callers upload n pairs of files per call. utilize toy example guide discussion.
imagine i'm collecting database of photos have been doctored. each record uploaded, need 2 files: (1) original photo, , (2) doctored photo. users upload records in batches. example, let's assume user upload 2 records.
i have considered 2 options:
nested forms:
curl -f "record=@orig0.jpg,doc0.jpg" -f "record=@orig1.jpg,doc1.jpg"
this results in top-level form parts containing records, each record contains sub-form parts photo files.
pros: logically accurate. can done curl.
cons: sub-form parts don't have field names. difficult through other clients.
form parts dynamic field names:
curl -f "record0_original=@orig0.jpg" -f "record0_doctored=@doc0.jpg" -f "record01_original=@orig1.jpg" -f "record1_doctored=@doc1.jpg"
pros: field labels present , expressive.
cons: uses dynamic field names impart structure.
is there option? there established design pattern specifying multiple binary files , relationships between them?
Comments
Post a Comment