Skip to content
This repository has been archived by the owner on Mar 9, 2020. It is now read-only.

Feature/UploadFile Service Implementation #22

Open
3 of 5 tasks
faraonc opened this issue Nov 17, 2018 · 2 comments
Open
3 of 5 tasks

Feature/UploadFile Service Implementation #22

faraonc opened this issue Nov 17, 2018 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@faraonc
Copy link
Member

faraonc commented Nov 17, 2018

Description

As a user, I want to upload a file to Azure Blob Storage.

Story Points

8

Definitions of Done

Algorithms & Resources

  • [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:
    1. Send the name. If you use oneof, then you may have to check how to use it doc because 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.
    2. 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.
    3. Set buffer=1st 1024 bytes.
    4. Send the buffer.
    5. Read/pipe and send the next 1024 bytes. Repeat step iii.
    6. 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.
@faraonc
Copy link
Member Author

faraonc commented Nov 17, 2018

Please refer to hwsc-org/hwsc-gateway-svc#43

@faraonc
Copy link
Member Author

faraonc commented Dec 1, 2018

Error types.

  • File not supported - INVALID_ARGUMENT
  • Max is 32MB - INVALID_ARGUMENT
  • Check for valid UUID using regex ^[[:digit:][:lower:]]{26}$ - INVLID_ARGUMENT
  • What if the UUID does not exist in Azure Blob Storage? - INVALID_ARGUMENT
  • Check for max length of file name in Azure Blob Storage, if max > 100, we go for 100, else we go with Azure's max. - INVALID_ARGUMENT
  • Azure is down - INTERNAL
  • What if something goes wrong with the USER? (Different size) - ABORTED

@kimlisa kimlisa transferred this issue from hwsc-org/hwsc-gateway-svc Dec 2, 2018
@faraonc faraonc changed the title Feature/hwsc-file-transaction-svc UploadFile Service Implementation Feature/UploadFile Service Implementation Dec 2, 2018
@faraonc faraonc added the enhancement New feature or request label Feb 27, 2019
@faraonc faraonc assigned acltang and unassigned yeseulan and dinhl Apr 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants