Skip to content

Instantly share code, notes, and snippets.

@jamiehodge
Last active December 17, 2015 14:09
Show Gist options
  • Save jamiehodge/5622811 to your computer and use it in GitHub Desktop.
Save jamiehodge/5622811 to your computer and use it in GitHub Desktop.
Upload protocols

Server ideals

  • stateless
  • tell, don't ask

Client ideals

  • graceful degredation (should be possible to manually split and submit files via forms)
  • a minimum of logic
    • chunk files
    • submit server-provided forms
  • Don't overload standard single-request/response POST

Variations

No upfront manifest

S3 (upload-as-bucket)

  • POST to / -> URL (actually an ID, but...)
  • POST repreatedly to URL
  • (optional) GET URL (?) for list of associated POSTs
  • POST with list of URLs to concat

Benefits from being fully-distributed.

The same could be done using PATCH

Upfront manifest

PATCH sequential

  • POST to / with total length -> URL
  • GET URL for PATCH form with server-specified byte start and stop values
  • Server stops serving PATCH form when length is reached

PATCH non-sequential (torrent-ish)

  • POST to / with total length -> URL
  • GET URL for rolling list of PUT or PATCH forms to specific chunks (maybe best with distinct URLs)

Minimal

  • POST to / with form containing hidden complete (default: true) and offset (default: 0) inputs
  • js sets complete to false -> server provides a PATCH form with an incrementing offset (and possibly end byte) value
  • js sets complete to true on last PATCH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment