http - How to model a REST API with "POST to PUT redirect"? -


i'm creating rest api backup service, in principle quite simple:

  • a user identified uid;
  • files identified fid;
  • to upload file, user posts file /backups/<uid> , location returned
  • to list files, user gets /backups/<uid> , index of fids returned
  • to download file, user picks 1 index, gets /backup/<uid>/<fid> , file returned.

now i'd reduce traffic server delegating up- , downloads service amazon s3.

redirecting downloads not problem, since perform regular redirect (301 or 307?) generated expiring url.

but uploads? hope have this:

  • a user (unaware of s3) starts post file server
  • the server receives headers (not whole file!)
  • the server determines place in s3, generates expiring url put , redirects it
  • the client puts file url handed server
  • the server notified of successful upload

the point needs transparent possible users.

i don't think initial post should include entire entity. rather, post must explicitly request "upload bucket" resource created. you'd respond post request 201 created, location header pointing new resource file should uploaded.

if upload bucket chosen must depend on specifics of file (file size, type), i'd let client submit metadata in post body.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -