Upload sample with pause/resume
See original GitHub issueWe’re trying to upload a large file and want to support pause/resume. However the upload doesn’t finish and is stuck in the while loop:
TransferManager.Configurations.BlockSize = 4 * 1024 * 1024; // 4 MB
// create stream with 100 MB
var content = Enumerable
.Range(0, 100 * 1024 * 1024)
.Select(i => (byte)'b')
.ToArray();
var source = new MemoryStream(content);
TransferCheckpoint checkPoint = null;
while (true)
{
Console.Write(".");
// Resume if there is already a checkpoint
var context = checkPoint != null
? new SingleTransferContext(checkPoint)
: new SingleTransferContext();
context.ShouldOverwriteCallback = (src, dest) => true;
context.LogLevel = Microsoft.WindowsAzure.Storage.LogLevel.Verbose;
var recorder = new ProgressRecorder();
context.ProgressHandler = recorder;
try
{
// Interrupt upload after 20 seconds
using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(20)))
{
await TransferManager.UploadAsync(source, blob, null, context, cts.Token);
}
// break if no exception occured, i.e. the upload finished
break;
}
catch (OperationCanceledException) { }
checkPoint = context.LastCheckpoint; // save the last checkpoint
}
What are we doing wrong?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:15 (5 by maintainers)
Top Results From Across the Web
Pause Resume File Upload using JavaScript
In this tutorial, we are going to see how to implement file upload with pause and resume options using FineUploader.
Read more >How to Pause Upload, Cancel Upload, Restore Broken ...
To pause the upload, you will simply break the connection. Call Stream.Close() on a stream object returned by IResumableUpload.
Read more >How to resume a paused or broken file upload
The idea is to provide the user with a button to pause an upload in progress and to resume it again later. Pausing...
Read more >Pause and resume file upload with dotnet core and javascript
All that has been posted is a program description, but that doesn't tell us what problem you're having. · Does this answer your...
Read more >Uploading File to Firebase with Pause and ... - YouTube
We will see how to pause and resume a download plus have a ... Upload Images / Files to Firebase In React -...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Once the upload is cancelled, you can save the checkpoint like this:
And to resume your upload from the saved checkpoint:
Then upload the file again with the above context object.
Is there a way to save context.LastCheckpoint in the database or as a file to use it later to start blob upload from the last checkpoint by using Azure Data Movement library?