You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.
we use discoveryapis_generator to generate the API for our own service. It is great, but we come to one issue - how to simply upload a file through the API.
We finded out one solution which readed file to upload and convert it to Media like this:
MediafileToMedia(File file) {
StreamController controller =newStreamController();
Media media =newMedia(controller.stream, 2, contentType: file.type);
FileReader reader =newFileReader();
reader.onLoad.listen((ProgressEvent ev) {
List rawList = reader.result;
Stream data =newStream.fromIterable(rawList.map((byte) => [byte]));
controller.addStream(data).then((_) {
controller.close();
});
});
reader.readAsArrayBuffer(file);
return media;
}
but it is very slow workaround, which loaded whole file to RAM (i think) and then upload it. This upload take really long and feeezes whole website, and sometimes causing "website does not respond" error.
Is there some better way to upload the file by the generated API, or should we perform the upload without using the API?
Thank you in advance.
Jakuub
The text was updated successfully, but these errors were encountered:
jakuub
changed the title
Browser support for uploading attachments
Browser support for uploading files
Jan 28, 2016
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello,
we use discoveryapis_generator to generate the API for our own service. It is great, but we come to one issue - how to simply upload a file through the API.
We finded out one solution which readed file to upload and convert it to Media like this:
but it is very slow workaround, which loaded whole file to RAM (i think) and then upload it. This upload take really long and feeezes whole website, and sometimes causing "website does not respond" error.
Is there some better way to upload the file by the generated API, or should we perform the upload without using the API?
Thank you in advance.
Jakuub
The text was updated successfully, but these errors were encountered: