2024-11-22 09:37:00 +03:00
|
|
|
URL = "storage-155.s3hoster.by";
|
2024-11-21 11:30:08 +03:00
|
|
|
AccessKey = "BRN5RKJE67...";
|
|
|
|
SecretKey = "NNhv+i9PrytpT8Tu0C1N...";
|
|
|
|
Region = "BTC";
|
|
|
|
|
|
|
|
BasicData = OPI_S3.GetBasicDataStructure(URL, AccessKey, SecretKey, Region);
|
|
|
|
|
|
|
|
Name = "fileChunked.mp3";
|
|
|
|
Bucket = "opi-gpbucket3";
|
|
|
|
|
|
|
|
Entity = "https://api.athenaeum.digital/test_data/song.mp3"; // URL, Path or Binary Data
|
|
|
|
Entity = OPI_Tools.Get(Entity);
|
|
|
|
|
|
|
|
Result = OPI_S3.InitPartsUpload(Name, Bucket, BasicData);
|
|
|
|
|
|
|
|
UploadID = Result["response"]["InitiateMultipartUploadResult"]["UploadId"];
|
|
|
|
TotalSize = Entity.Size();
|
|
|
|
ChunkSize = 5242880;
|
|
|
|
BytesRead = 0;
|
|
|
|
PartNumber = 1;
|
|
|
|
|
|
|
|
DataReader = New DataReader(Entity);
|
|
|
|
SourceStream = DataReader.SourceStream();
|
|
|
|
TagsArray = New Array;
|
|
|
|
|
|
|
|
WHile BytesRead < TotalSize Do
|
|
|
|
|
|
|
|
CurrentReading = DataReader.Read(ChunkSize);
|
|
|
|
CurrentData = CurrentReading.GetBinaryData();
|
|
|
|
|
|
|
|
If CurrentData.Size() = 0 Then
|
|
|
|
Break;
|
|
|
|
EndIf;
|
|
|
|
|
2024-11-22 09:37:00 +03:00
|
|
|
Result = OPI_S3.UploadObjectPart(Name, Bucket, BasicData, UploadID, PartNumber,
|
|
|
|
CurrentData);
|
2024-11-21 11:30:08 +03:00
|
|
|
|
|
|
|
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
|
|
|
BytesRead = SourceStream.CurrentPosition();
|
|
|
|
TagsArray.Add(Result["headers"]["Etag"]);
|
|
|
|
|
|
|
|
Break;
|
|
|
|
|
|
|
|
PartNumber = PartNumber + 1;
|
|
|
|
|
|
|
|
EndDo;
|
|
|
|
|
|
|
|
Result = OPI_S3.FinishPartsUpload(Name, Bucket, BasicData, UploadID, TagsArray);
|