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.