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

Blob upload dosn't work #75

Open
Crafter6432 opened this issue Nov 10, 2015 · 1 comment
Open

Blob upload dosn't work #75

Crafter6432 opened this issue Nov 10, 2015 · 1 comment

Comments

@Crafter6432
Copy link

Hello,

I tried to use the new MediaMessage but that only seems to work from server to client,
if the client uploads binary data the Apihandler always gets MediaMessage.bytes = null.

Request:
https://gist.github.com/Crafter6432/1c0f5948704212d40913

Relevant code:
https://gist.github.com/Crafter6432/9f14529346239fee864e

rpc version: 0.5.5

@tristancaron
Copy link
Contributor

Hello,

Thank you for your return.

It's actually because you are not sending a MediaMessage, but a binary, or whatever else.

A MediaMessage has fields such as bytes, contentType, etc.

If you want handle your file, you must provide a structure.

class RequestMessage {
  MediaMessage myFile;
}

@ApiMethod(method: 'POST', path: 'file/{id}')
Future<ResourceMessage> storeFile(String id, RequestMessage request) async {
  if (request.myFile.bytes == null || request.myFile.bytes.isEmpty) {
    throw new BadRequestError("No data received");
  }

  // store your file, request.myFile.bytes

  return new ResourceMessage();
}

The curl command which you allow to do that is
curl -F myFile=@/path/to/my_file.txt http://localhost:8080/cloud/v1/file/abcdef

I think we could fix this issue easily, but I'm not sure it fit with the RPC process. However, it could throw a format error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants