Open Crafter6432 opened 8 years ago
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.
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