직접이 문제를 해결하는 것이 좋다고 들었습니다. 모든 업로드에서 토큰을 새로 고침하면이 문제가 해결 될 수 있지만 큰 파일을 청크로 업로드하려면 buckets/:bucketKey/objects/:objectName/resumable
을 사용하는 것이 좋습니다.
대용량 파일의 경우 공식 document에 청크라는 작은 부품으로 분리하여 buckets/:bucketKey/objects/:objectName/resumable
API로 업로드하는 것이 좋습니다.
private static dynamic resumableUploadFile()
{
Console.WriteLine("*****Start uploading file to the OSS");
string path = FILE_PATH;
if (!File.Exists(path))
path = @"..\..\..\" + FILE_PATH;
//File Total size
long fileSize = new System.IO.FileInfo(path).Length;
//Chunk size for separting file into several parts.
//2MB chuck size is used in this sample.
long chunkSize = 2 * 1024 * 1024 ;
//Total amounts of chunks in 2MB size.
long nbChunks = (long)Math.Round(0.5 + (double)fileSize/(double)chunkSize);
ApiResponse<dynamic> finalRes = null ;
using (FileStream streamReader = new FileStream(path, FileMode.Open))
{
//Unique id for resumable uploading.
string sessionId = RandomString(12);
for (int i = 0; i < nbChunks; i++)
{
//Start position in bytes of a chunk
long start = i * chunkSize;
//End position in bytes of a chunk
//(End posistion of the latest chuck is the total file size in bytes)
long end = Math.Min(fileSize, (i + 1) * chunkSize) - 1;
//Identify chunk info. to the Forge
string range = "bytes " + start + "-" + end + "/" + fileSize;
//Steam size for this chunk
long length = end - start + 1;
Console.WriteLine("Uploading range: " + range);
//Read content stream into a meomery stream for this chunk
byte[] buffer = new byte[length];
MemoryStream memoryStream = new MemoryStream(buffer);
int nb = streamReader.Read(buffer, 0, (int)length);
memoryStream.Write(buffer, 0, nb);
memoryStream.Position = 0;
//Upload file to the Forge OSS Bucket
ApiResponse<dynamic> response = objectsApi.UploadChunk(
BUCKET_KEY,
FILE_NAME,
(int)length,
range,
sessionId,
memoryStream
);
finalRes = response;
if (response.StatusCode == 202) {
Console.WriteLine("One chunk uploaded successfully");
continue;
}
else if (response.StatusCode == 200)
{
Console.WriteLine("Final chunk uploaded successfully");
}
else
{
//Some error occurred here
Console.WriteLine(response.StatusCode);
break;
}
}
}
return (finalRes);
}
희망이 도움말 : 여기 내 동료에서이 API에 대한 the Forge C# SDK의 C#을 샘플입니다.
파일에 대해이 API 호출에 소요되는 시간은 얼마나됩니까? 30 분 이상 걸리면 사용한 토큰이 만료되기 전에 새로 고쳐야합니다. –
답장을 보내 주셔서 감사합니다. 파일 크기는 155MB 였고 aprox를 사용했습니다. 업로드 2 분. 동시에 업로드 할 때 Autodesk의 종료에는 제한이 있습니까? –
나를 위해 Forge 버킷에 업로드 된 파일의 총 크기를 확인할 수 있습니까? 내 경험에 따르면, api'oss/v2/buckets/{key}/objects/{object}'로 20MB보다 큰 파일을 업로드하는 데 실패 할 것입니다. –