Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling large binary data transfers #294

Closed
jayrbolton opened this issue May 26, 2020 · 7 comments
Closed

Handling large binary data transfers #294

jayrbolton opened this issue May 26, 2020 · 7 comments

Comments

@jayrbolton
Copy link

For example, you might have an HTTP endpoint for uploading images. Typically, this would be handled with a multipart/form-data request. What would be the best way to handle this with an OpenRPC API?

@github-actions
Copy link

Welcome to OpenRPC! Thank you for taking the time to create an issue. Please review the guidelines

@BelfordZ
Copy link
Member

BelfordZ commented Jun 9, 2020

Hi @jayrbolton

Thank you for the question. JSON-RPC makes no suggestions over this type of http-specific challenge.

That being said, perhaps you could construct a custom http transport that handles batch requests as multipart, and then have an open-rpc method called something like upload-big-file-chunk ?

I'm not exactly sure what the best way to handle this would be since json-rpc and thus open-rpc is meant to be transport agnostic.

please feel free to share any solutions you come across for dealing with this. Thanks!

@jayrbolton
Copy link
Author

Hey @BelfordZ, I had similar thoughts. Here are my ideas in another issue:
kbaseincubator/jsonrpcbase#20

In the issue, I mention leaning towards the CBOR/BSON way, because it keeps the transport agnosticism. But I'm still not crazy about it because I think it'd be pretty tricky to stream only one nested param to a file without loading the whole payload into memory.

I feel like the multi-part way would be easier to stream the binary data to a file, without the surrounding json structure, and that seems important. But it would be HTTP-specific.

I do realize this is not the responsibility of the Open-RPC layer, but is more of a tangential problem. Feel free to close if you'd like.

@shanejonas
Copy link
Member

shanejonas commented Jun 9, 2020

Just some more info to add to the thread:

I'd recommend base64 as its used in web more often, not sure how they compare.

you can validate non-json data like base64 for example, or probably your own, with JSON-Schema:

https://json-schema.org/understanding-json-schema/reference/non_json_data.html

@jayrbolton
Copy link
Author

jayrbolton commented Jun 10, 2020

Nice, I never saw that part of json-schema, that feature is definitely a plus here.

A couple downsides of embedding base64: you're increasing the size of your file data and the payload, which definitely matters for large uploads; it's still tricky to stream only the upload content to a local file on the server without loading any surrounding rpc structure into memory.

@BelfordZ
Copy link
Member

@jayrbolton All the good solutions I can think of are a bit departed from JSON-RPC 2.0. Perhaps its something to add to the list of things to support in JSON-RPC 3.0 whenever we gather the courage to put that together =P

Any new ideas about this since above?

@stale
Copy link

stale bot commented Aug 27, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 27, 2020
@stale stale bot closed this as completed Sep 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants