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 Mar 9, 2020. It is now read-only.
[OPTION 1 (PREFERRED)] Learn how to use createReadStream, link on how to pipe, link on how to set the chunk size. Code may look like the following:
const fs = require('fs');
const server = client.UploadFile....
server.send({name : "some name"})
const readStream = fs.createReadStream('myfile.txt'); //read the doc and learn how to use highWaterMark
readStream
.on('readable', function () {
let chunk;
while (null !== (chunk = readStream.read())) {
//do something like server.send({buffer : chunk)
}
})
.on('end', function () {
//do something server.end() or is it close()?
});
.on('error', function () {
//do something server.cancel()
})
[OPTION 2] Learn how to read a file in node.js in 1MB chunks; sample 1, sample 2, more npm library for reading file in chunks link.
The algorithm for the UploadFile in the client should be the following:
Send the name. If you use oneof, then you may have to check how to use it docbecause of oneof you can only send 1 at a time! From the doc, unlike regular fields, at most one of the fields in a oneof can be set at a time, so setting one field will clear the others. Also note that if you are using proto3, the compiler generates has.. and clear.. accessors for oneof fields, even for scalar types.
Open the file, and read/pipe the first 1024 bytes of the file. The ideal way is to pipe and to send the 1024 bytes, instead of reading before sending 1024 bytes. The reading is technically unnecessary.
Set buffer=1st 1024 bytes.
Send the buffer.
Read/pipe and send the next 1024 bytes. Repeat step iii.
Obviously and highly possible, the last chunk will not be 1024 bytes. We may or may NOT have to add extra logic for the last read/pipe and send.
The text was updated successfully, but these errors were encountered:
Description
As a user, I want to upload a file to Azure Blob Storage.
Story Points
8
Definitions of Done
service.py
andutility.py
Algorithms & Resources
oneof
, then you may have to check how to use it doc because ofoneof
you can only send 1 at a time! From the doc,unlike regular fields, at most one of the fields in a oneof can be set at a time, so setting one field will clear the others. Also note that if you are using proto3, the compiler generates has.. and clear.. accessors for oneof fields, even for scalar types.
buffer=1st 1024 bytes
.The text was updated successfully, but these errors were encountered: