I'm facing with an error when uploading files to sharepoint,
An unhandled exception occurred while processing the request. AggregateException: One or more errors occurred. Unknown location TaskCanceledException: Upload failed too many times. See InnerException for list of exceptions that occured. Microsoft.Graph.LargeFileUploadTask.UploadAsync(IProgress progress, int maxTries)
This is the code used:
using (FileStream fileStream = System.IO.File.OpenRead(filePath))
{
// Use properties to specify the conflict behavior
// in this case, replace
var uploadProps = new DriveItemUploadableProperties
{
ODataType = null,
AdditionalData = new Dictionary<string, object>
{
{ "@microsoft.graph.conflictBehavior", "replace" }
}
};
var uploadSession = await _graphServiceClient.Drives["b!G_sdavHlaEmqc9oVvd2b-WJ1ylhoxrtPt9v6xJPy1RQH5vGZK44uQau0-P9QCo5r"]
.Root
.ItemWithPath(file.FileName)
.CreateUploadSession(uploadProps)
.Request()
.PostAsync();
// Max slice size must be a multiple of 320 KiB
int maxSliceSize = 320 * 1024;
var fileUploadTask =
new LargeFileUploadTask<DriveItem>(uploadSession, fileStream, maxSliceSize);
// Create a callback that is invoked after each slice is uploaded
IProgress<long> progress = new Progress<long>(prog => {
Console.WriteLine($"Uploaded {prog} bytes of {fileStream.Length} bytes");
});
try
{
// Upload the file
var uploadResult = await fileUploadTask.UploadAsync(progress);
if (uploadResult.UploadSucceeded)
{
// The ItemResponse object in the result represents the
// created item.
Console.WriteLine($"Upload complete, item ID: {uploadResult.ItemResponse.Id}");
}
else
{
Console.WriteLine("Upload failed");
}
}
catch (ServiceException ex)
{
Console.WriteLine($"Error uploading: {ex.ToString()}");
}
}
But we see the
Creaste ~tmp95_Manipulador de Alimentos GUERO...pdf en ex3 Hace un minuto
On the sharepoint folder where we're trying to store, this means that some temporaly file has been created on the folder, but not the final file
Any clue about this problem??