You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
RealProgrammer
4 years agoExplorer | Level 4
System.ArgumentNullException: when inititating concurrent upload
Hi, I've been working on a project and the requirement is to upload files to Dropbox concurrently and in chunks. So, I wrote the following code to accomplish the task.
I initiated the request using the following code.
public async Task<string> InitiateChunkUploadAsync(ProcessFileViewModel fileModel, CancellationToken cancellationToken) { try { _logger.LogInformation($"Initiating multi part upload to Dropbox."); var uploadSessionStartResult = await _client.Files.UploadSessionStartAsync(sessionType: UploadSessionType.Concurrent.Instance); return uploadSessionStartResult.SessionId; } catch (DropboxException ex) { _logger.LogError(ex, $"An error occurred while initiating multi part upload to Dropbox."); } catch (Exception ex) { _logger.LogError(ex, $"An error occurred while initiating multi part upload to Dropbox."); } }
and I'm getting the following error
System.ArgumentNullException: Value cannot be null. (Parameter 'body') at MultiPartChunkUpload.Web.Services.Storage.DropboxUploadService.InitiateChunkUploadAsync(ProcessFileViewModel fileModel, CancellationToken cancellationToken) in ... at MultiPartChunkUpload.Web.Controllers.FileController.SaveChunkOnDropBoxAsync(IFormFileCollection files, ChunkMetaData chunkMetaData, ChunkUploadFileResult chunkUploadFileResult, CancellationToken cancellationToken) in ... at MultiPartChunkUpload.Web.Controllers.FileController.SaveToCloud(CloudProvider cloudProvider, IFormFileCollection files, ChunkMetaData chunkMetaData, CancellationToken cancellationToken) ... at MultiPartChunkUpload.Web.Controllers.FileController.ChunkSave(IFormFileCollection files, String metaData, CancellationToken cancellationToken) in ...
When I tried to add body in the UploadSessionStartAsync, as below
var uploadSessionStartResult = await _client.Files.UploadSessionStartAsync(sessionType: UploadSessionType.Concurrent.Instance, body: fileModel.Stream);
I got another error, which is expecting
Dropbox.Api.ApiException`1[Dropbox.Api.Files.UploadSessionStartError]: concurrent_session_data_not_allowed/ at MultiPartChunkUpload.Web.Services.Storage.DropboxUploadService.InitiateChunkUploadAsync(ProcessFileViewModel fileModel, CancellationToken cancellationToken) in ... at MultiPartChunkUpload.Web.Controllers.FileController.SaveChunkOnDropBoxAsync(IFormFileCollection files, ChunkMetaData chunkMetaData, ChunkUploadFileResult chunkUploadFileResult, CancellationToken cancellationToken) in ... at MultiPartChunkUpload.Web.Controllers.FileController.SaveToCloud(CloudProvider cloudProvider, IFormFileCollection files, ChunkMetaData chunkMetaData, CancellationToken cancellationToken) in ... at MultiPartChunkUpload.Web.Controllers.FileController.ChunkSave(IFormFileCollection files, String metaData, CancellationToken cancellationToken) in ...; Request Id: 71753a2c841a4de284321c8aab374bdf
I've looked at the source code and found this line problematic. Looks like chunk concurrent operation is not yet implemented in .NET SDK.
Can someone please guide me if there is an error with my code or I figured it out correctly that this is not implemented? If not implemented yet, any workaround or when we expect this to be implemented?
Thanks in advance.
Apologies for the confusion. You can start a concurrent upload session in the .NET SDK by passing an empty body, like this:
var uploadSessionStartResult = await _client.Files.UploadSessionStartAsync(sessionType: UploadSessionType.Concurrent.Instance, body: new MemoryStream());
I'll ask the team to see if we can update the SDK to make this easier/more obvious in the future.
- Greg-DBDropbox Staff
Apologies for the confusion. You can start a concurrent upload session in the .NET SDK by passing an empty body, like this:
var uploadSessionStartResult = await _client.Files.UploadSessionStartAsync(sessionType: UploadSessionType.Concurrent.Instance, body: new MemoryStream());
I'll ask the team to see if we can update the SDK to make this easier/more obvious in the future.
- RealProgrammerExplorer | Level 4
Thanks for the help. Your answer did the trick.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,884 PostsLatest Activity: 3 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!