You've already forked OpenIntegrations
mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2025-11-27 22:18:36 +02:00
58 lines
1.7 KiB
Plaintext
Vendored
58 lines
1.7 KiB
Plaintext
Vendored
URL = "storage-155.s3hoster.by";
|
|
AccessKey = "BRN5RKJE67...";
|
|
SecretKey = "NNhv+i9PrytpT8Tu0C1N...";
|
|
Region = "BTC";
|
|
|
|
BasicData = OPI_S3.GetBasicDataStructure(URL, AccessKey, SecretKey, Region);
|
|
|
|
Name = "fileChunked.mp3";
|
|
|
|
Directory = True; // Formation URL in path-style
|
|
Bucket = "opi-dirbucket3";
|
|
Entity = "https://hut.openintegrations.dev/test_data/song.mp3"; // URL, Path or Binary Data
|
|
Entity = OPI_HTTPRequests.Get(Entity);
|
|
|
|
Result = OPI_S3.InitPartsUpload(Name, Bucket, BasicData, , Directory);
|
|
|
|
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;
|
|
|
|
Result = OPI_S3.UploadObjectPart(Name
|
|
, Bucket
|
|
, BasicData
|
|
, UploadID
|
|
, PartNumber
|
|
, CurrentData
|
|
, Directory);
|
|
|
|
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
BytesRead = SourceStream.CurrentPosition();
|
|
|
|
ETag = Result["headers"]["Etag"];
|
|
ETag = ?(ETag = Undefined, Result["headers"]["ETag"], ETag);
|
|
|
|
TagsArray.Add(ETag);
|
|
|
|
PartNumber = PartNumber + 1;
|
|
|
|
EndDo;
|
|
|
|
Result = OPI_S3.FinishPartsUpload(Name, Bucket, BasicData, UploadID, TagsArray, , Directory);
|