cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

System.ArgumentNullException: when inititating concurrent upload

System.ArgumentNullException: when inititating concurrent upload

RealProgrammer
Explorer | Level 4
Go to solution

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.

 

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

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.

View solution in original post

4 Replies 4

Greg-DB
Dropbox Staff
Go to solution

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.

RealProgrammer
Explorer | Level 4
Go to solution

Thanks for the help. Your answer did the trick.

9krausec
Explorer | Level 4
Go to solution

Hey @Greg-DB - Have any pointers on the correct syntax to do this with Python?

 

Greg-DB
Dropbox Staff
Go to solution

@9krausec I don't believe we have a sample of this in Python handy unfortunately. I see you have an open ticket with support about this though so we'll take a look at that and follow up with you there.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
  • User avatar
    9krausec Explorer | Level 4
  • User avatar
    RealProgrammer Explorer | Level 4
What do Dropbox user levels mean?