feat: add Motoko fileupload example#205
Conversation
| The fileupload is done in chunks, to support uploading larger files than 2MB, which is the ingress limit. Uploaded files are stored in an asset canister, which can serve assets like image files. | ||
|
|
||
| ### Motoko backend | ||
| The backend functions are located in the `src/fileupload/main.mo` Motoko file. The backend can receive a batch of chunks of a file, when a file is uploaded in the frontend, and when the batch is complete, it stores the file in the asset canister. The backend also includes functionality to serve the file to the frontend. |
| @@ -0,0 +1,8329 @@ | |||
| { | |||
There was a problem hiding this comment.
Should package-lock.json be checked in. Is it for the other examples? Perhaps @krpeacock or @chenyan-dfinity can advise
There was a problem hiding this comment.
package-lock can be checked
|
|
||
| switch (chunk) { | ||
| case (?{content}) { | ||
| content_chunks := Array.append<[Nat8]>(content_chunks, [content]); |
There was a problem hiding this comment.
| content_chunks := Array.append<[Nat8]>(content_chunks, [content]); | |
| content_chunks := Array.append<[Nat8]>(content_chunks, [content]); |
Array.append in a loop is quadratic. Is chunk_ids just [0,1, ...,n) for some consecutive indices? In that case, you could use Array.tabulate<[Nat8]>(n, func i { ...}) to create the outer array without fear of 0(n^2) behaviour.
There was a problem hiding this comment.
(but I don't fully grok this code, tbh)
| @@ -0,0 +1,165 @@ | |||
| import Text "mo:base/Text"; | |||
There was a problem hiding this comment.
ideally, ident by 2 not 4 spaces (as in your README, I think)
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
Co-authored-by: Claudio Russo <claudio@dfinity.org>
|
I think we could revisit this and get it in - most of the concerns were addressed. @carstenjacobsen would you like any support here? |
|
Dear @carstenjacobsen, In order to potentially merge your code in this open-source repository and therefore proceed with your contribution, we need to have your approval on DFINITY's CLA. If you decide to agree with it, please visit this issue and read the instructions there. Once you have signed it, re-trigger the workflow on this PR to see if your code can be merged. — The DFINITY Foundation |

No description provided.