问题
im trying to build out a project, that users can upload small videos to and ive created this class to handle my cloudinary code on how to upload a video. it works fine for videos that are very short like 0.3 sec videos but when i try to upload more than 0.10 secs worth i get an exception "System.Net.Http.HttpRequestException: Error while copying content to a stream." The videos are being uploaded to cloudinary heres the code
public class VideoAccessor : IVideoAccessor
{
private readonly Cloudinary _cloudinary;
public VideoAccessor(IConfiguration config)
{
// instantiate a new instance of cloudinary using details provided
_cloudinary = new Cloudinary(config["cloudinary"]);
}
public VideoUploadResult UploadClip(IFormFile videoFile)
{
var uploadResult = new CloudinaryDotNet.Actions.VideoUploadResult();
if (videoFile.Length > 0)
{
// create a new file stream to upload the video to cloudinary
using (var filestream = videoFile.OpenReadStream())
{
var uploadParams = new VideoUploadParams
{
File = new FileDescription(videoFile.FileName, filestream),
Transformation = new Transformation().StartOffset("0").EndOffset("120").Crop("fill")
};
uploadResult = _cloudinary.Upload(uploadParams);
}
}
// checks if error occurs when uploading video
if (uploadResult.Error != null)
{
throw new Exception(uploadResult.Error.Message);
}
return new VideoUploadResult
{
PublicId = uploadResult.PublicId,
Url = uploadResult.SecureUrl.AbsoluteUri
};
}
}
}
when it to upload.. i get an exception... does anyone know what i can add to this or how to make it more acceptable for larger files?
the stack trace
System.Threading.Tasks.TaskCanceledException: The operation was canceled.
System.Net.Http.HttpRequestException: Error while copying content to a stream.
System.IO.IOException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request
System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request.
来源:https://stackoverflow.com/questions/64277867/httprequestexception-error-while-copying-content-to-a-stream-cloudinary-upload