Adding Chunk File Upload Support to the library #977
Reference in New Issue
Block a user
Delete Branch "PauloPeres/development"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixing Issues #880 and #435
With just a few tweeks on the implemations you can use the chunk file upload method.
4 new Parameters
and 1 new callback to change the link of that specifc item on the request
Codecov Report
24.36% <17.54%> (+0.17%)27.53% <27.53%> (ø)24.82% <32.55%> (+3.39%)Continue to review full report at Codecov.
How can I use this to chunk file upload support to Azure storage, Is there any documentation available?
@mbaljeetsingh Hi man as you requested i added a little bit more examples on the ReadMe of my Branch
https://github.com/PauloPeres/ng2-file-upload
I'm currently using with Azure Blob-Storage as well, but i don't recommend using the Angular Code directly to connect with your Blob Storage because this Might Expose your credentials to the Client side.
On your Server side create the logic to make the bridge between the received chunk and the Blob-Storage.
Hope this helps!
Thanks I'll take a look. I'm actually getting sas token based on the logged in user credentials. So, it seems secure 😉
@PauloPeres Can you push your code to separate npm package? Otherwise I think I have to copy paste the updated files to ng2-file-upload node_modules folder.
Is there's a better solution?
@mbaljeetsingh Hi Man....
So i did not wanted to push to the NPM becuase i woudl like to see someone whos taking care of the ng2-file-upload to put it to work.
in the meantine what i did with my projects is:
added the folder src in my project and i'm using the typescript package this way i can change and improve as i go.
If i dont get response from de delovelopers for too long will put on the NPM :D
Ok, I'll give it a try like this
@PauloPeres Got the import working for your code.
Here's my working code without Chunk support, I'm using dynamic URL for each file.
As I'm using SAS token, I'm not sure how should I set the item URL in the case of adding chunk support.
I'm tring to update your code as follows,
As I'm not updating URL in the

this.uploader.onAfterAddingAll, I'm getting the following error,So, I'm stuck. Can you suggest, how should I go about If I need to use SAS token?
@mbaljeetsingh use the onBeforeUploadItem and set item.url as the url you need for that specif item to be posting the chunks
@PauloPeres Updated the URL in onBeforeUploadItem, But when the upload start it is doing post request on the URL, so getting the error (The resource doesn't support specified Http Verb.)

Shouldn't it send the put request?
@PauloPeres I updated the uploader object with method and headers,
Now it seems to start uploading, but I'm not getting any response back in
onCompleteChunkSo it's getting error on the uploadcheck the uploader.onErrorItem callback to see if the first chunk is going or what kind of error you are getting from it. i don't know who you should send data to the blob storage letting it know what chunk number you are sending,
This link has documentation for it.
The first post should be POST with information about the chunks
https://docs.microsoft.com/en-us/rest/api/storageservices/reliable-uploads-to-blob-storage-via-an-html5-control
@PauloPeres Can you share how you structured your API, I may ask the developer to make modifications accordingly?
I'm getting the following response on both
onErrorItem&onCompleteChunk,The problem I think is, when we use SAS token, It is expecting a put request to the url similar to the following,
We also need to pass the header,
Console

@mbaljeetsingh Hello Again : )
The API we work is built in Pythonwe used the Azure Blobl SDK and used teh AppendBlobService To append the chunks
On the Logic we first create the Blob Storage give it the name and the start content (first chunk), after that we have a Blob Storage Reference to work on the next chunk requests.
Then every new chunk we user the AppendBlobService to append the data
You should be able to copy the same logic to TypeScript
Theres useful information on the Node Module from Microsoft
Create the stream for a new file http://azure.github.io/azure-storage-node/FileService.html#createWriteStreamToNewFile
Create the stream for an existing file http://azure.github.io/azure-storage-node/FileService.html#createWriteStreamToExistingFile__anchor
@PauloPeres Any chance you can publish this to your own npm project? It appears the devs behind ng2-file-upload haven't made any changes or been active on this project in a long time. I would really like to use the chunk file upload if possible.
definitely would like to see this as an npm project
Hi @ph3n0m666 ad @bvercelli99 Sorry for taking to long.
I'm still working on the NPM Package, it's my first time so i'm losing my virginity.
On the path of doing so, i updated the version of the Package to use Angular 6, and Instead of using the links, use a Service, this way we can have more control over the functions of the upload.
Will be trying to send that NPM Package ASAP! It's a little bit complicated because of the Day-to-Day Stuff :D
@PauloPeres Just came across this on my search for an easier solution to uploading to Azure Blob Storage, I'm using the preview to do it with Azure Active Directory tokens which should be just great to use on the client side.
Not being able to find this on npm made me a bit weary of using it, is this still something that's going on or has the main ng2-file-upload picked up on the chunk feature?
Was this ever moved to a separate repo and published on npm?
@MgSam never done it... Let me update to Angular 7 and will deploy it to NPM
Looks promising. Tried to npm install it from git repo and build it but there were some issues, so I guess ones best bet is to copy changes manually or wait for the official package to be released. Thanks @PauloPeres !
Hi @PauloPeres,
Is there any possibility to publish this feature to ng2-file-upload? This really helpful and match exactly what I'm looking for.
@PauloPeres is there any way to abort a chunk upload process? Because item.cancel() not workinkg in chunk model.
The cancel should work. After the first chevuk is accepted, só dont allow
your user to delete a file before having the first chunk
Em qui, 12 de mar de 2020 12:27, Mehmet notifications@github.com escreveu:
@PauloPeres i cancel process in
onCompleteChunkmethod, there is not any fail but upload process go on, i think afteronCompleteChunk = (item:FileItem, response, status, headers) => item.cancel()upload process should abort but it doesn't.
@PauloPeres Is commit
5a84b9eb0c (diff-b8aa3b862dc83fee3efcdc29e54d959b)valid ? I want to handle failed chunk uploadsorry for the delay
i'm trying to work that on a separated npm package
but for now the latests commits are in the : https://github.com/myog-io/ngx-chunk-file-upload
Kind Regards
Paulo Peres Jr
Phone: +1 (818) 279-3840 (tel:+1%20(818)%20279-3840)
WhatsApp: +55 14 98225-0396 (https://api.whatsapp.com/send?phone=5514982250396)
On Apr 9 2020, at 5:47 am, Gopal Zadafiya notifications@github.com wrote:
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.