mirror of
https://github.com/Bayselonarrend/OpenIntegrations.git
synced 2025-03-19 21:17:55 +02:00
Main build (Jenkins)
This commit is contained in:
parent
188f8866e2
commit
b4832464b9
@ -1616,11 +1616,11 @@ def test_s3(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
powershell encoding: 'UTF-8', script:'./oint.exe s3 SendRequestWithoutBody --method "test" --basic "test" --headers "test" --debug --test '
|
powershell encoding: 'UTF-8', script:'./oint.exe s3 SendRequestWithoutBody --method "test" --basic "test" --binary "test" --headers "test" --debug --test '
|
||||||
}
|
}
|
||||||
|
|
||||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
powershell encoding: 'UTF-8', script:'./oint.exe s3 SendRequestWithBody --method "test" --basic "test" --body "test" --headers "test" --debug --test '
|
powershell encoding: 'UTF-8', script:'./oint.exe s3 SendRequestWithBody --method "test" --basic "test" --body "test" --binary "test" --headers "test" --debug --test '
|
||||||
}
|
}
|
||||||
|
|
||||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
@ -1679,6 +1679,10 @@ def test_s3(){
|
|||||||
powershell encoding: 'UTF-8', script:'./oint.exe s3 HeadObject --name "test" --bucket "test" --basic "test" --ver "test" --headers "test" --debug --test '
|
powershell encoding: 'UTF-8', script:'./oint.exe s3 HeadObject --name "test" --bucket "test" --basic "test" --ver "test" --headers "test" --debug --test '
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
|
powershell encoding: 'UTF-8', script:'./oint.exe s3 GetObject --name "test" --bucket "test" --basic "test" --dir "test" --ver "test" --headers "test" --out "test" --debug --test '
|
||||||
|
}
|
||||||
|
|
||||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
powershell encoding: 'UTF-8', script:'./oint.exe s3 DeleteObject --name "test" --bucket "test" --basic "test" --ver "test" --headers "test" --debug --test '
|
powershell encoding: 'UTF-8', script:'./oint.exe s3 DeleteObject --name "test" --bucket "test" --basic "test" --ver "test" --headers "test" --debug --test '
|
||||||
}
|
}
|
||||||
|
@ -1616,11 +1616,11 @@ def test_s3(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
powershell encoding: 'UTF-8', script:'./oint.exe s3 ОтправитьЗапросБезТела --method "test" --basic "test" --headers "test" --debug --test '
|
powershell encoding: 'UTF-8', script:'./oint.exe s3 ОтправитьЗапросБезТела --method "test" --basic "test" --binary "test" --headers "test" --debug --test '
|
||||||
}
|
}
|
||||||
|
|
||||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
powershell encoding: 'UTF-8', script:'./oint.exe s3 ОтправитьЗапросСТелом --method "test" --basic "test" --body "test" --headers "test" --debug --test '
|
powershell encoding: 'UTF-8', script:'./oint.exe s3 ОтправитьЗапросСТелом --method "test" --basic "test" --body "test" --binary "test" --headers "test" --debug --test '
|
||||||
}
|
}
|
||||||
|
|
||||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
@ -1679,6 +1679,10 @@ def test_s3(){
|
|||||||
powershell encoding: 'UTF-8', script:'./oint.exe s3 ПолучитьОписаниеОбъекта --name "test" --bucket "test" --basic "test" --ver "test" --headers "test" --debug --test '
|
powershell encoding: 'UTF-8', script:'./oint.exe s3 ПолучитьОписаниеОбъекта --name "test" --bucket "test" --basic "test" --ver "test" --headers "test" --debug --test '
|
||||||
}
|
}
|
||||||
|
|
||||||
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
|
powershell encoding: 'UTF-8', script:'./oint.exe s3 ПолучитьОбъект --name "test" --bucket "test" --basic "test" --dir "test" --ver "test" --headers "test" --out "test" --debug --test '
|
||||||
|
}
|
||||||
|
|
||||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||||
powershell encoding: 'UTF-8', script:'./oint.exe s3 УдалитьОбъект --name "test" --bucket "test" --basic "test" --ver "test" --headers "test" --debug --test '
|
powershell encoding: 'UTF-8', script:'./oint.exe s3 УдалитьОбъект --name "test" --bucket "test" --basic "test" --ver "test" --headers "test" --debug --test '
|
||||||
}
|
}
|
||||||
|
5
docs/en/data/S3/GetObject.json
Normal file
5
docs/en/data/S3/GetObject.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"URL": "storage-155.s3hoster.by",
|
||||||
|
"AccessKey": "BRN5RKJE67...",
|
||||||
|
"SecretKey": "NNhv+i9PrytpT8Tu0C1N..."
|
||||||
|
}
|
16
docs/en/examples/S3/GetObject.txt
Normal file
16
docs/en/examples/S3/GetObject.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
URL = "storage-155.s3hoster.by";
|
||||||
|
AccessKey = "BRN5RKJE67...";
|
||||||
|
SecretKey = "NNhv+i9PrytpT8Tu0C1N...";
|
||||||
|
Region = "BTC";
|
||||||
|
|
||||||
|
BasicData = OPI_S3.GetBasicDataStructure(URL, AccessKey, SecretKey, Region);
|
||||||
|
|
||||||
|
Name = "picture.jpg";
|
||||||
|
Bucket = "opi-gpbucket3";
|
||||||
|
|
||||||
|
Result = OPI_S3.GetObject(Name, Bucket, BasicData);
|
||||||
|
|
||||||
|
TempFile = GetTempFileName();
|
||||||
|
BasicData.Insert("ChunkSize", 200000);
|
||||||
|
|
||||||
|
Result = OPI_S3.GetObject(Name, Bucket, BasicData, , , TempFile);
|
@ -10,13 +10,14 @@ import TabItem from '@theme/TabItem';
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
`Function SendRequestWithBody(Val Method, Val BasicData, Val Body, Val Headers = Undefined) Export`
|
`Function SendRequestWithBody(Val Method, Val BasicData, Val Body, Val ExpectedBinary = False, Val Headers = Undefined) Export`
|
||||||
|
|
||||||
| Parameter | CLI option | Type | Required | Description |
|
| Parameter | CLI option | Type | Required | Description |
|
||||||
|-|-|-|-|-|
|
|-|-|-|-|-|
|
||||||
| Method | --method | String | ✔ | HTTP method |
|
| Method | --method | String | ✔ | HTTP method |
|
||||||
| BasicData | --basic | Structure of KeyAndValue | ✔ | Basic request data (with full URL). See GetBasicDataStructure |
|
| BasicData | --basic | Structure of KeyAndValue | ✔ | Basic request data (with full URL). See GetBasicDataStructure |
|
||||||
| Body | --body | String, BinaryData | ✔ | Binary data or file of request body data |
|
| Body | --body | String, BinaryData | ✔ | Binary data or file of request body data |
|
||||||
|
| ExpectedBinary | --binary | Boolean | ✖ | Disables an attempt to convert the response to JSON |
|
||||||
| Headers | --headers | Map Of KeyAndValue | ✖ | Additional request headers, if necessary |
|
| Headers | --headers | Map Of KeyAndValue | ✖ | Additional request headers, if necessary |
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,12 +10,13 @@ import TabItem from '@theme/TabItem';
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
`Function SendRequestWithoutBody(Val Method, Val BasicData, Val Headers = Undefined) Export`
|
`Function SendRequestWithoutBody(Val Method, Val BasicData, Val ExpectedBinary = False, Val Headers = Undefined) Export`
|
||||||
|
|
||||||
| Parameter | CLI option | Type | Required | Description |
|
| Parameter | CLI option | Type | Required | Description |
|
||||||
|-|-|-|-|-|
|
|-|-|-|-|-|
|
||||||
| Method | --method | String | ✔ | HTTP method |
|
| Method | --method | String | ✔ | HTTP method |
|
||||||
| BasicData | --basic | Structure of KeyAndValue | ✔ | Basic request data (with full URL). See GetBasicDataStructure |
|
| BasicData | --basic | Structure of KeyAndValue | ✔ | Basic request data (with full URL). See GetBasicDataStructure |
|
||||||
|
| ExpectedBinary | --binary | Boolean | ✖ | Disables an attempt to convert the response to JSON |
|
||||||
| Headers | --headers | Map Of KeyAndValue | ✖ | Additional request headers, if necessary |
|
| Headers | --headers | Map Of KeyAndValue | ✖ | Additional request headers, if necessary |
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 4
|
sidebar_position: 5
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 7
|
sidebar_position: 8
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 3
|
sidebar_position: 4
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 6
|
sidebar_position: 7
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
|
64
docs/en/md/S3/Objects-managment/Get-object.mdx
Normal file
64
docs/en/md/S3/Objects-managment/Get-object.mdx
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
---
|
||||||
|
sidebar_position: 3
|
||||||
|
---
|
||||||
|
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
|
# Get object
|
||||||
|
Gets the contents of the object from the bucket
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
`Function GetObject(Val Name, Val Bucket, Val BasicData, Val Version = "", Val Headers = Undefined, Val SavePath = "") Export`
|
||||||
|
|
||||||
|
| Parameter | CLI option | Type | Required | Description |
|
||||||
|
|-|-|-|-|-|
|
||||||
|
| Name | --name | String | ✔ | Name of the object in the bucket |
|
||||||
|
| Bucket | --bucket | String | ✔ | Name of the bucket in which the object is stored |
|
||||||
|
| BasicData | --basic | Structure of KeyAndValue | ✔ | Basic request data. See GetBasicDataStructure |
|
||||||
|
| Directory | --dir | Boolean | ✔ | True > Directory Bucket, False > General Purpose Bucket |
|
||||||
|
| Version | --ver | String | ✖ | Token for receiving a specific version of an object |
|
||||||
|
| Headers | --headers | Map Of KeyAndValue | ✖ | Additional request headers, if necessary |
|
||||||
|
| SavePath | --out | String | ✖ | Path to directly write a file to disk |
|
||||||
|
|
||||||
|
|
||||||
|
Returns: Structure of KeyAndValue - serialized JSON response from storage
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
Method at AWS documentation: [GetObjectAttributes](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectAttributes.html)
|
||||||
|
|
||||||
|
You can use the `ChunkSize` field in the basic data to specify the minimum file and chunk size for a chunked upload
|
||||||
|
|
||||||
|
For example, ChunkSize=X means that all files larger than X (in bytes) will be downloaded in chunks, where one chunk will be of size X.
|
||||||
|
|
||||||
|
Chunk upload is used for large files. Default ChunkSize - 20000000 bytes (20 MB)
|
||||||
|
:::
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
```bsl title="1C:Enterprise/OneScript code example"
|
||||||
|
URL = "storage-155.s3hoster.by";
|
||||||
|
AccessKey = "BRN5RKJE67...";
|
||||||
|
SecretKey = "NNhv+i9PrytpT8Tu0C1N...";
|
||||||
|
Region = "BTC";
|
||||||
|
|
||||||
|
BasicData = OPI_S3.GetBasicDataStructure(URL, AccessKey, SecretKey, Region);
|
||||||
|
|
||||||
|
Name = "picture.jpg";
|
||||||
|
Bucket = "opi-gpbucket3";
|
||||||
|
|
||||||
|
Result = OPI_S3.GetObject(Name, Bucket, BasicData);
|
||||||
|
|
||||||
|
TempFile = GetTempFileName();
|
||||||
|
BasicData.Insert("ChunkSize", 200000);
|
||||||
|
|
||||||
|
Result = OPI_S3.GetObject(Name, Bucket, BasicData, , , TempFile);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 9
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 8
|
sidebar_position: 9
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 5
|
sidebar_position: 6
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
|
5
docs/ru/data/S3/ПолучитьОбъект.json
Normal file
5
docs/ru/data/S3/ПолучитьОбъект.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"URL": "storage-155.s3hoster.by",
|
||||||
|
"AccessKey": "BRN5RKJE67...",
|
||||||
|
"SecretKey": "NNhv+i9PrytpT8Tu0C1N..."
|
||||||
|
}
|
16
docs/ru/examples/S3/ПолучитьОбъект.txt
Normal file
16
docs/ru/examples/S3/ПолучитьОбъект.txt
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
URL = "storage-155.s3hoster.by";
|
||||||
|
AccessKey = "BRN5RKJE67...";
|
||||||
|
SecretKey = "NNhv+i9PrytpT8Tu0C1N...";
|
||||||
|
Region = "BTC";
|
||||||
|
|
||||||
|
ОсновныеДанные = OPI_S3.ПолучитьСтруктуруДанных(URL, AccessKey, SecretKey, Region);
|
||||||
|
|
||||||
|
Наименование = "picture.jpg";
|
||||||
|
Бакет = "opi-gpbucket3";
|
||||||
|
|
||||||
|
Результат = OPI_S3.ПолучитьОбъект(Наименование, Бакет, ОсновныеДанные);
|
||||||
|
|
||||||
|
ВременныйФайл = ПолучитьИмяВременногоФайла();
|
||||||
|
ОсновныеДанные.Вставить("ChunkSize", 200000);
|
||||||
|
|
||||||
|
Результат = OPI_S3.ПолучитьОбъект(Наименование, Бакет, ОсновныеДанные, , , ВременныйФайл);
|
@ -10,13 +10,14 @@ import TabItem from '@theme/TabItem';
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
`Функция ОтправитьЗапросСТелом(Знач Метод, Знач ОсновныеДанные, Знач Тело, Знач Заголовки = Неопределено) Экспорт`
|
`Функция ОтправитьЗапросСТелом(Знач Метод, Знач ОсновныеДанные, Знач Тело, Знач ОжидаютсяДвоичные = Ложь, Знач Заголовки = Неопределено) Экспорт`
|
||||||
|
|
||||||
| Параметр | CLI опция | Тип | Обяз. | Назначение |
|
| Параметр | CLI опция | Тип | Обяз. | Назначение |
|
||||||
|-|-|-|-|-|
|
|-|-|-|-|-|
|
||||||
| Метод | --method | Строка | ✔ | HTTP метод |
|
| Метод | --method | Строка | ✔ | HTTP метод |
|
||||||
| ОсновныеДанные | --basic | Структура Из КлючИЗначение | ✔ | Основные данные запроса (c полным URL). См. ПолучитьСтруктуруДанных |
|
| ОсновныеДанные | --basic | Структура Из КлючИЗначение | ✔ | Основные данные запроса (c полным URL). См. ПолучитьСтруктуруДанных |
|
||||||
| Тело | --body | Строка, ДвоичныеДанные | ✔ | Двоичное тело запроса или путь к файлу |
|
| Тело | --body | Строка, ДвоичныеДанные | ✔ | Двоичное тело запроса или путь к файлу |
|
||||||
|
| ОжидаютсяДвоичные | --binary | Булево | ✖ | Отключает попытку преобразования ответа в JSON |
|
||||||
| Заголовки | --headers | Соответствие Из КлючИЗначение | ✖ | Дополнительные заголовки запроса, если необходимо |
|
| Заголовки | --headers | Соответствие Из КлючИЗначение | ✖ | Дополнительные заголовки запроса, если необходимо |
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,12 +10,13 @@ import TabItem from '@theme/TabItem';
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
`Функция ОтправитьЗапросБезТела(Знач Метод, Знач ОсновныеДанные, Знач Заголовки = Неопределено) Экспорт`
|
`Функция ОтправитьЗапросБезТела(Знач Метод, Знач ОсновныеДанные, Знач ОжидаютсяДвоичные = Ложь, Знач Заголовки = Неопределено) Экспорт`
|
||||||
|
|
||||||
| Параметр | CLI опция | Тип | Обяз. | Назначение |
|
| Параметр | CLI опция | Тип | Обяз. | Назначение |
|
||||||
|-|-|-|-|-|
|
|-|-|-|-|-|
|
||||||
| Метод | --method | Строка | ✔ | HTTP метод |
|
| Метод | --method | Строка | ✔ | HTTP метод |
|
||||||
| ОсновныеДанные | --basic | Структура Из КлючИЗначение | ✔ | Основные данные запроса (c полным URL). См. ПолучитьСтруктуруДанных |
|
| ОсновныеДанные | --basic | Структура Из КлючИЗначение | ✔ | Основные данные запроса (c полным URL). См. ПолучитьСтруктуруДанных |
|
||||||
|
| ОжидаютсяДвоичные | --binary | Булево | ✖ | Отключает попытку преобразования ответа в JSON |
|
||||||
| Заголовки | --headers | Соответствие Из КлючИЗначение | ✖ | Дополнительные заголовки запроса, если необходимо |
|
| Заголовки | --headers | Соответствие Из КлючИЗначение | ✖ | Дополнительные заголовки запроса, если необходимо |
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 4
|
sidebar_position: 5
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 7
|
sidebar_position: 8
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 3
|
sidebar_position: 4
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 6
|
sidebar_position: 7
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
|
64
docs/ru/md/S3/Objects-managment/Get-object.mdx
Normal file
64
docs/ru/md/S3/Objects-managment/Get-object.mdx
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
---
|
||||||
|
sidebar_position: 3
|
||||||
|
---
|
||||||
|
|
||||||
|
import Tabs from '@theme/Tabs';
|
||||||
|
import TabItem from '@theme/TabItem';
|
||||||
|
|
||||||
|
# Получить объект
|
||||||
|
Получает содержимое объекта из бакета
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
`Функция ПолучитьОбъект(Знач Наименование, Знач Бакет, Знач ОсновныеДанные, Знач Версия = "", Знач Заголовки = Неопределено, Знач ПутьСохранения = "") Экспорт`
|
||||||
|
|
||||||
|
| Параметр | CLI опция | Тип | Обяз. | Назначение |
|
||||||
|
|-|-|-|-|-|
|
||||||
|
| Наименование | --name | Строка | ✔ | Наименование объекта в бакете |
|
||||||
|
| Бакет | --bucket | Строка | ✔ | Имя бакета, в котором находится объект |
|
||||||
|
| ОсновныеДанные | --basic | Структура Из КлючИЗначение | ✔ | Основные данные запроса. См. ПолучитьСтруктуруДанных |
|
||||||
|
| Каталог | --dir | Булево | ✔ | Истина > Directory Bucket, Ложь > General Purpose Bucket |
|
||||||
|
| Версия | --ver | Строка | ✖ | Токен для получения конкретной версии объекта |
|
||||||
|
| Заголовки | --headers | Соответствие Из КлючИЗначение | ✖ | Дополнительные заголовки запроса, если необходимо |
|
||||||
|
| ПутьСохранения | --out | Строка | ✖ | Путь для прямой записи файла на диск |
|
||||||
|
|
||||||
|
|
||||||
|
Возвращаемое значение: Структура Из КлючИЗначение - сериализованный JSON ответа от хранилища
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
Метод в документации AWS: [GetObjectAttributes](https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectAttributes.html)
|
||||||
|
|
||||||
|
Вы можете использовать поле `ChunkSize` в основных данных для указания минимального размера и величины чанка загрузки по частям
|
||||||
|
|
||||||
|
Например, ChunkSize=X означает, что все файлы, размером больше X (в байтах) будут загружаться по частям, где одна часть будет размером X.
|
||||||
|
|
||||||
|
Загрузка по частям используется для больших файлов. Стандартный размер ChunkSize - 20000000 байт (20 МБайт)
|
||||||
|
:::
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
```bsl title="Пример использования для 1С:Предприятие/OneScript"
|
||||||
|
URL = "storage-155.s3hoster.by";
|
||||||
|
AccessKey = "BRN5RKJE67...";
|
||||||
|
SecretKey = "NNhv+i9PrytpT8Tu0C1N...";
|
||||||
|
Region = "BTC";
|
||||||
|
|
||||||
|
ОсновныеДанные = OPI_S3.ПолучитьСтруктуруДанных(URL, AccessKey, SecretKey, Region);
|
||||||
|
|
||||||
|
Наименование = "picture.jpg";
|
||||||
|
Бакет = "opi-gpbucket3";
|
||||||
|
|
||||||
|
Результат = OPI_S3.ПолучитьОбъект(Наименование, Бакет, ОсновныеДанные);
|
||||||
|
|
||||||
|
ВременныйФайл = ПолучитьИмяВременногоФайла();
|
||||||
|
ОсновныеДанные.Вставить("ChunkSize", 200000);
|
||||||
|
|
||||||
|
Результат = OPI_S3.ПолучитьОбъект(Наименование, Бакет, ОсновныеДанные, , , ВременныйФайл);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 9
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
@ -47,4 +47,45 @@ import TabItem from '@theme/TabItem';
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```json title="Результат"
|
||||||
|
{
|
||||||
|
"status": 200,
|
||||||
|
"response": {
|
||||||
|
"ListVersionsResult": {
|
||||||
|
"Name": "opi-gpbucket3",
|
||||||
|
"Prefix": "pic",
|
||||||
|
"KeyMarker": {},
|
||||||
|
"NextVersionIdMarker": {},
|
||||||
|
"VersionIdMarker": {},
|
||||||
|
"MaxKeys": "250",
|
||||||
|
"IsTruncated": "false",
|
||||||
|
"Version": {
|
||||||
|
"Key": "picture.jpg",
|
||||||
|
"LastModified": "2024-11-18T19:36:29.948Z",
|
||||||
|
"ETag": "\"9e0176f87f6565a22f78e0f9b39a4d78\"",
|
||||||
|
"Size": "2114023",
|
||||||
|
"Owner": {
|
||||||
|
"ID": "02d6176db174dc93cb1b899f7c6078f08654445fe8cf1b6ce98d8855f66bdbf4",
|
||||||
|
"DisplayName": "minio"
|
||||||
|
},
|
||||||
|
"StorageClass": "STANDARD",
|
||||||
|
"IsLatest": "true",
|
||||||
|
"VersionId": "null"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"headers": {
|
||||||
|
"Accept-Ranges": "bytes",
|
||||||
|
"Content-Length": "707",
|
||||||
|
"Content-Type": "application/xml",
|
||||||
|
"Date": "Mon, 18 Nov 2024 19:36:46 GMT",
|
||||||
|
"Server": "MinIO",
|
||||||
|
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
|
||||||
|
"Vary": "Origin,Accept-Encoding",
|
||||||
|
"X-Amz-Id-2": "93c576aa54c960b355da9e2934476635fe3243f5df9dbb4db8b7c0d94bec7cd1",
|
||||||
|
"X-Amz-Request-Id": "1809272D137CB06E",
|
||||||
|
"X-Content-Type-Options": "nosniff",
|
||||||
|
"X-Xss-Protection": "1; mode=block"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 8
|
sidebar_position: 9
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
@ -46,4 +46,37 @@ import TabItem from '@theme/TabItem';
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
```json title="Результат"
|
||||||
|
{
|
||||||
|
"status": 200,
|
||||||
|
"response": {
|
||||||
|
"ListBucketResult": {
|
||||||
|
"Name": "opi-gpbucket3",
|
||||||
|
"Prefix": {},
|
||||||
|
"KeyCount": "1",
|
||||||
|
"MaxKeys": "250",
|
||||||
|
"IsTruncated": "false",
|
||||||
|
"Contents": {
|
||||||
|
"Key": "picture.jpg",
|
||||||
|
"LastModified": "2024-11-18T19:36:29.948Z",
|
||||||
|
"ETag": "\"9e0176f87f6565a22f78e0f9b39a4d78\"",
|
||||||
|
"Size": "2114023",
|
||||||
|
"StorageClass": "STANDARD"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"headers": {
|
||||||
|
"Accept-Ranges": "bytes",
|
||||||
|
"Content-Length": "451",
|
||||||
|
"Content-Type": "application/xml",
|
||||||
|
"Date": "Mon, 18 Nov 2024 19:36:46 GMT",
|
||||||
|
"Server": "MinIO",
|
||||||
|
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
|
||||||
|
"Vary": "Origin,Accept-Encoding",
|
||||||
|
"X-Amz-Id-2": "e602da57d0c30b8c7034fcfe129917205f80f7bab979408e71da5d1441c85e79",
|
||||||
|
"X-Amz-Request-Id": "1809272D121882D8",
|
||||||
|
"X-Content-Type-Options": "nosniff",
|
||||||
|
"X-Xss-Protection": "1; mode=block"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
sidebar_position: 5
|
sidebar_position: 6
|
||||||
---
|
---
|
||||||
|
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -77,13 +77,17 @@ EndFunction
|
|||||||
// Parameters:
|
// Parameters:
|
||||||
// Method - String - HTTP method - method
|
// Method - String - HTTP method - method
|
||||||
// BasicData - Structure of KeyAndValue - Basic request data (with full URL). See GetBasicDataStructure - basic
|
// BasicData - Structure of KeyAndValue - Basic request data (with full URL). See GetBasicDataStructure - basic
|
||||||
|
// ExpectedBinary - Boolean - Disables an attempt to convert the response to JSON - binary
|
||||||
// Headers - Map Of KeyAndValue - Additional request headers, if necessary - headers
|
// Headers - Map Of KeyAndValue - Additional request headers, if necessary - headers
|
||||||
//
|
//
|
||||||
// Returns:
|
// Returns:
|
||||||
// Structure of KeyAndValue - serialized JSON response from storage
|
// Structure of KeyAndValue - serialized JSON response from storage
|
||||||
Function SendRequestWithoutBody(Val Method, Val BasicData, Val Headers = Undefined) Export
|
Function SendRequestWithoutBody(Val Method
|
||||||
|
, Val BasicData
|
||||||
|
, Val ExpectedBinary = False
|
||||||
|
, Val Headers = Undefined) Export
|
||||||
|
|
||||||
Response = SendRequest(Method, BasicData, , Headers);
|
Response = SendRequest(Method, BasicData, , ExpectedBinary, Headers);
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
@ -95,13 +99,18 @@ EndFunction
|
|||||||
// Method - String - HTTP method - method
|
// Method - String - HTTP method - method
|
||||||
// BasicData - Structure of KeyAndValue - Basic request data (with full URL). See GetBasicDataStructure - basic
|
// BasicData - Structure of KeyAndValue - Basic request data (with full URL). See GetBasicDataStructure - basic
|
||||||
// Body - String, BinaryData - Binary data or file of request body data - body
|
// Body - String, BinaryData - Binary data or file of request body data - body
|
||||||
|
// ExpectedBinary - Boolean - Disables an attempt to convert the response to JSON - binary
|
||||||
// Headers - Map Of KeyAndValue - Additional request headers, if necessary - headers
|
// Headers - Map Of KeyAndValue - Additional request headers, if necessary - headers
|
||||||
//
|
//
|
||||||
// Returns:
|
// Returns:
|
||||||
// Structure of KeyAndValue - serialized JSON response from storage
|
// Structure of KeyAndValue - serialized JSON response from storage
|
||||||
Function SendRequestWithBody(Val Method, Val BasicData, Val Body, Val Headers = Undefined) Export
|
Function SendRequestWithBody(Val Method
|
||||||
|
, Val BasicData
|
||||||
|
, Val Body
|
||||||
|
, Val ExpectedBinary = False
|
||||||
|
, Val Headers = Undefined) Export
|
||||||
|
|
||||||
Response = SendRequest(Method, BasicData, Body, Headers);
|
Response = SendRequest(Method, BasicData, Body, ExpectedBinary, Headers);
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
@ -216,7 +225,7 @@ Function PutBucketEncryption(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithBody("PUT", BasicData, XmlConfig, Headers);
|
Response = SendRequestWithBody("PUT", BasicData, XmlConfig, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -248,7 +257,7 @@ Function GetBucketEncryption(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("GET", BasicData, Headers);
|
Response = SendRequestWithoutBody("GET", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -280,7 +289,7 @@ Function DeleteBucketEncryption(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("DELETE", BasicData, Headers);
|
Response = SendRequestWithoutBody("DELETE", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -318,7 +327,7 @@ Function PutBucketTagging(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithBody("PUT", BasicData, TagsXML, Headers);
|
Response = SendRequestWithBody("PUT", BasicData, TagsXML, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -349,7 +358,7 @@ Function GetBucketTagging(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("GET", BasicData, Headers);
|
Response = SendRequestWithoutBody("GET", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -380,7 +389,7 @@ Function DeleteBucketTagging(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("DELETE", BasicData, Headers);
|
Response = SendRequestWithoutBody("DELETE", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -419,7 +428,7 @@ Function PutBucketVersioning(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithBody("PUT", BasicData, TagsXML, Headers);
|
Response = SendRequestWithBody("PUT", BasicData, TagsXML, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -450,7 +459,7 @@ Function GetBucketVersioning(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("GET", BasicData, Headers);
|
Response = SendRequestWithoutBody("GET", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -488,7 +497,7 @@ Function ListBuckets(Val BasicData
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("GET", BasicData, Headers);
|
Response = SendRequestWithoutBody("GET", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -527,7 +536,7 @@ Function PutObject(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequest("PUT", BasicData, Entity, Headers);
|
Response = SendRequest("PUT", BasicData, Entity, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -570,13 +579,68 @@ Function HeadObject(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithBody("HEAD", BasicData, Headers);
|
Response = SendRequestWithoutBody("HEAD", BasicData, , Headers);
|
||||||
Response["response"] = New Structure;
|
Response["response"] = New Structure;
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
|
// Get object
|
||||||
|
// Gets the contents of the object from the bucket
|
||||||
|
//
|
||||||
|
// Note
|
||||||
|
// Method at AWS documentation: [GetObjectAttributes](@docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectAttributes.html)
|
||||||
|
// You can use the `ChunkSize` field in the basic data to specify the minimum file and chunk size for a chunked upload
|
||||||
|
// For example, ChunkSize=X means that all files larger than X (in bytes) will be downloaded in chunks, where one chunk will be of size X.
|
||||||
|
// Chunk upload is used for large files. Default ChunkSize - 20000000 bytes (20 MB)
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
// Name - String - Name of the object in the bucket - name
|
||||||
|
// Bucket - String - Name of the bucket in which the object is stored - bucket
|
||||||
|
// BasicData - Structure of KeyAndValue - Basic request data. See GetBasicDataStructure - basic
|
||||||
|
// Directory - Boolean - True > Directory Bucket, False > General Purpose Bucket - dir
|
||||||
|
// Version - String - Token for receiving a specific version of an object - ver
|
||||||
|
// Headers - Map Of KeyAndValue - Additional request headers, if necessary - headers
|
||||||
|
// SavePath - String - Path to directly write a file to disk - out
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// Structure of KeyAndValue - serialized JSON response from storage
|
||||||
|
Function GetObject(Val Name
|
||||||
|
, Val Bucket
|
||||||
|
, Val BasicData
|
||||||
|
, Val Version = ""
|
||||||
|
, Val Headers = Undefined
|
||||||
|
, Val SavePath = "") Export
|
||||||
|
|
||||||
|
If OPI_Tools.CollectionFieldExist(BasicData, "ChunkSize") Then
|
||||||
|
MaxSize = BasicData["ChunkSize"];
|
||||||
|
Else
|
||||||
|
MaxSize = 20000000;
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
ObjectInfo = HeadObject(Name, Bucket, BasicData, Version);
|
||||||
|
|
||||||
|
If Not OPI_Tools.CollectionFieldExist(ObjectInfo, "headers.Content-Length") Then
|
||||||
|
Return ObjectInfo;
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
ObjectSize = ObjectInfo["headers"]["Content-Length"];
|
||||||
|
|
||||||
|
OPI_TypeConversion.GetNumber(MaxSize);
|
||||||
|
OPI_TypeConversion.GetNumber(ObjectSize);
|
||||||
|
|
||||||
|
If ObjectSize > MaxSize Then
|
||||||
|
Sizes = New Structure("object,chunk", ObjectSize, MaxSize);
|
||||||
|
Response = GetObjectInChunks(BasicData, Headers, SavePath, Sizes);
|
||||||
|
Else
|
||||||
|
Response = GetFullObject(BasicData, Headers, SavePath);
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
Return Response;
|
||||||
|
|
||||||
|
EndFunction
|
||||||
|
|
||||||
// Delete object
|
// Delete object
|
||||||
// Removes the object from the bucket
|
// Removes the object from the bucket
|
||||||
//
|
//
|
||||||
@ -613,7 +677,7 @@ Function DeleteObject(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithBody("DELETE", BasicData, Headers);
|
Response = SendRequestWithoutBody("DELETE", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -692,7 +756,7 @@ Function PutObjectTagging(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithBody("PUT", BasicData, TagsXML, Headers);
|
Response = SendRequestWithBody("PUT", BasicData, TagsXML, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -732,7 +796,7 @@ Function GetObjectTagging(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("GET", BasicData, Headers);
|
Response = SendRequestWithoutBody("GET", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -772,7 +836,7 @@ Function DeleteObjectTagging(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("DELETE", BasicData, Headers);
|
Response = SendRequestWithoutBody("DELETE", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -811,7 +875,7 @@ Function ListObjects(Val Bucket
|
|||||||
URL = URL + OPI_Tools.RequestParametersToString(Parameters);
|
URL = URL + OPI_Tools.RequestParametersToString(Parameters);
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("GET", BasicData, Headers);
|
Response = SendRequestWithoutBody("GET", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -850,7 +914,7 @@ Function ListObjectVersions(Val Bucket
|
|||||||
URL = URL + OPI_Tools.RequestParametersToString(Parameters, , False);
|
URL = URL + OPI_Tools.RequestParametersToString(Parameters, , False);
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("GET", BasicData, Headers);
|
Response = SendRequestWithoutBody("GET", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -1140,7 +1204,11 @@ EndProcedure
|
|||||||
|
|
||||||
#Region Miscellaneous
|
#Region Miscellaneous
|
||||||
|
|
||||||
Function SendRequest(Val Method, Val BasicData, Val Body = Undefined, Val Headers = Undefined)
|
Function SendRequest(Val Method
|
||||||
|
, Val BasicData
|
||||||
|
, Val Body = Undefined
|
||||||
|
, Val ExpectedBinary = False
|
||||||
|
, Val Headers = Undefined)
|
||||||
|
|
||||||
CheckBasicData(BasicData);
|
CheckBasicData(BasicData);
|
||||||
|
|
||||||
@ -1164,7 +1232,7 @@ Function SendRequest(Val Method, Val BasicData, Val Body = Undefined, Val Header
|
|||||||
Request.Headers.Insert("Authorization", AuthorizationHeader);
|
Request.Headers.Insert("Authorization", AuthorizationHeader);
|
||||||
|
|
||||||
Response = OPI_Tools.ExecuteRequest(Request, Connection, Method, , True);
|
Response = OPI_Tools.ExecuteRequest(Request, Connection, Method, , True);
|
||||||
Response = FormResponse(Response);
|
Response = FormResponse(Response, ExpectedBinary);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -1177,12 +1245,122 @@ Function BucketManagment(Val Name, Val BasicData, Val Directory, Val Method, Val
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody(Method, BasicData, Headers);
|
Response = SendRequestWithoutBody(Method, BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
|
Function GetObjectInChunks(Val BasicData
|
||||||
|
, Val Headers
|
||||||
|
, Val SavePath
|
||||||
|
, Val Sizes)
|
||||||
|
|
||||||
|
TotalSize = Sizes["object"];
|
||||||
|
ChunkSize = Sizes["chunk"];
|
||||||
|
HeaderTemplate = "bytes=%1-%2";
|
||||||
|
ChunkStart = 0;
|
||||||
|
|
||||||
|
HeadersArray = New Array;
|
||||||
|
|
||||||
|
WHile ChunkStart < TotalSize - ChunkSize Do
|
||||||
|
|
||||||
|
ChunkEnd = ChunkStart + ChunkSize - 1;
|
||||||
|
|
||||||
|
StartStr = OPI_Tools.NumberToString(ChunkStart);
|
||||||
|
EndStr = OPI_Tools.NumberToString(ChunkEnd);
|
||||||
|
|
||||||
|
Title = StrTemplate(HeaderTemplate, StartStr, EndStr);
|
||||||
|
HeadersArray.Add(New Structure("Header,Position", Title, EndStr));
|
||||||
|
|
||||||
|
ChunkStart = ChunkEnd + 1;
|
||||||
|
|
||||||
|
EndDo;
|
||||||
|
|
||||||
|
If Not ChunkStart = TotalSize Then
|
||||||
|
|
||||||
|
Title = "bytes=" + OPI_Tools.NumberToString(ChunkStart) + "-";
|
||||||
|
|
||||||
|
DataStructure = New Structure("Header,Position", Title, TotalSize);
|
||||||
|
HeadersArray.Add(DataStructure);
|
||||||
|
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
If ValueIsFilled(SavePath) Then
|
||||||
|
StreamOfFile = New FileStream(SavePath, FileOpenMode.Create);
|
||||||
|
Else
|
||||||
|
StreamOfFile = New MemoryStream();
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
FileWriter = New DataWriter(StreamOfFile);
|
||||||
|
|
||||||
|
For Each CurrentSet In HeadersArray Do
|
||||||
|
|
||||||
|
For N = 1 To 3 Do
|
||||||
|
|
||||||
|
Try
|
||||||
|
|
||||||
|
ChunkHeader = CurrentSet["Title"];
|
||||||
|
CurrentPosition = CurrentSet["Item"];
|
||||||
|
|
||||||
|
SourceHeader = New Map();
|
||||||
|
SourceHeader.Insert("Range", ChunkHeader);
|
||||||
|
AddAdditionalHeaders(Headers, SourceHeader);
|
||||||
|
|
||||||
|
InterimResult = GetFullObject(BasicData, SourceHeader);
|
||||||
|
FileWriter.Write(InterimResult);
|
||||||
|
|
||||||
|
KBytes = 1024;
|
||||||
|
MByte = KBytes * KBytes;
|
||||||
|
Message(OPI_Tools.ProgressInformation(CurrentPosition, TotalSize, "MB", MByte));
|
||||||
|
|
||||||
|
RunGarbageCollection();
|
||||||
|
FreeObject(InterimResult);
|
||||||
|
|
||||||
|
Break;
|
||||||
|
|
||||||
|
Except
|
||||||
|
|
||||||
|
If N = 3 Then
|
||||||
|
Message(ErrorDescription());
|
||||||
|
Break;
|
||||||
|
Else
|
||||||
|
Message("Chunk upload error " + String(N) + "/3");
|
||||||
|
Continue;
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
EndTry;
|
||||||
|
|
||||||
|
EndDo;
|
||||||
|
|
||||||
|
EndDo;
|
||||||
|
|
||||||
|
FileWriter.Close();
|
||||||
|
|
||||||
|
If TypeOf(StreamOfFile) = Type("MemoryStream") Then
|
||||||
|
Return StreamOfFile.CloseAndGetBinaryData();
|
||||||
|
Else
|
||||||
|
StreamOfFile.Close();
|
||||||
|
Return New Structure("file", SavePath);
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
EndFunction
|
||||||
|
|
||||||
|
Function GetFullObject(Val BasicData
|
||||||
|
, Val Headers
|
||||||
|
, Val SavePath = "")
|
||||||
|
|
||||||
|
Response = SendRequestWithoutBody("GET", BasicData, True, Headers);
|
||||||
|
|
||||||
|
If ValueIsFilled(SavePath) Then
|
||||||
|
Response.Write(SavePath);
|
||||||
|
Return New Structure("file", SavePath);
|
||||||
|
Else
|
||||||
|
Return Response;
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
EndFunction
|
||||||
|
|
||||||
Function FormResponse(Val Response, Val ExpectedBinary = False)
|
Function FormResponse(Val Response, Val ExpectedBinary = False)
|
||||||
|
|
||||||
Status = Response.StatusCode;
|
Status = Response.StatusCode;
|
||||||
|
@ -2155,6 +2155,7 @@ Procedure AWS_ObjectsManagment() Export
|
|||||||
S3_DeleteObjectTagging(TestParameters);
|
S3_DeleteObjectTagging(TestParameters);
|
||||||
S3_ListObjects(TestParameters);
|
S3_ListObjects(TestParameters);
|
||||||
S3_ListObjectVersions(TestParameters);
|
S3_ListObjectVersions(TestParameters);
|
||||||
|
S3_GetObject(TestParameters);
|
||||||
S3_DeleteObject(TestParameters);
|
S3_DeleteObject(TestParameters);
|
||||||
S3_DeleteBucket(TestParameters);
|
S3_DeleteBucket(TestParameters);
|
||||||
|
|
||||||
@ -15053,6 +15054,16 @@ Procedure S3_PutObject(FunctionParameters)
|
|||||||
|
|
||||||
OPI_TestDataRetrieval.WriteLog(Result, "PutObject", "S3");
|
OPI_TestDataRetrieval.WriteLog(Result, "PutObject", "S3");
|
||||||
OPI_TestDataRetrieval.Check_S3Success(Result);
|
OPI_TestDataRetrieval.Check_S3Success(Result);
|
||||||
|
BasicData.Insert("URL", FunctionParameters["S3_URL"]);
|
||||||
|
|
||||||
|
Bucket = "opi-dirbucket3";
|
||||||
|
Result = OPI_S3.PutObject(Name, Bucket, Entity, BasicData);
|
||||||
|
|
||||||
|
OPI_TestDataRetrieval.WriteLog(Result, "PutObject (DB)", "S3");
|
||||||
|
OPI_TestDataRetrieval.Check_S3Success(Result);
|
||||||
|
BasicData.Insert("URL", FunctionParameters["S3_URL"]);
|
||||||
|
|
||||||
|
OPI_S3.DeleteObject(Name, Bucket, BasicData);
|
||||||
|
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
@ -15232,6 +15243,60 @@ Procedure S3_ListObjectVersions(FunctionParameters)
|
|||||||
|
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure S3_GetObject(FunctionParameters)
|
||||||
|
|
||||||
|
Image = FunctionParameters["Picture"]; // SKIP
|
||||||
|
OPI_TypeConversion.GetBinaryData(Image); // SKIP
|
||||||
|
RequiredSize = Image.Size(); // SKIP
|
||||||
|
|
||||||
|
URL = FunctionParameters["S3_URL"];
|
||||||
|
AccessKey = FunctionParameters["S3_AccessKey"];
|
||||||
|
SecretKey = FunctionParameters["S3_SecretKey"];
|
||||||
|
Region = "BTC";
|
||||||
|
|
||||||
|
BasicData = OPI_S3.GetBasicDataStructure(URL, AccessKey, SecretKey, Region);
|
||||||
|
|
||||||
|
Name = "picture.jpg";
|
||||||
|
Bucket = "opi-gpbucket3";
|
||||||
|
|
||||||
|
Result = OPI_S3.GetObject(Name, Bucket, BasicData);
|
||||||
|
|
||||||
|
OPI_TestDataRetrieval.WriteLog(Result, "GetObject", "S3"); // SKIP
|
||||||
|
OPI_TestDataRetrieval.Check_BinaryData(Result, RequiredSize); // SKIP
|
||||||
|
BasicData.Insert("URL", FunctionParameters["S3_URL"]); // SKIP
|
||||||
|
|
||||||
|
TempFile = GetTempFileName();
|
||||||
|
BasicData.Insert("ChunkSize", 200000);
|
||||||
|
|
||||||
|
Result = OPI_S3.GetObject(Name, Bucket, BasicData, , , TempFile);
|
||||||
|
|
||||||
|
// END
|
||||||
|
|
||||||
|
OPI_TestDataRetrieval.WriteLog(Result, "GetObject (file)", "S3");
|
||||||
|
ResultFile = New File(Result["file"]);
|
||||||
|
OPI_TestDataRetrieval.ExpectsThat(ResultFile.Size() = RequiredSize);
|
||||||
|
BasicData.Insert("URL", FunctionParameters["S3_URL"]);
|
||||||
|
DeleteFiles(TempFile);
|
||||||
|
|
||||||
|
Name = "bigfile.exe";
|
||||||
|
Bucket = "newbucket2";
|
||||||
|
|
||||||
|
BigTempFile = GetTempFileName();
|
||||||
|
Result = OPI_S3.GetObject(Name, Bucket, BasicData, , , BigTempFile);
|
||||||
|
ResultFile = New File(Result["file"]);
|
||||||
|
|
||||||
|
OPI_TestDataRetrieval.WriteLog(Result, "GetObject (big, file)", "S3");
|
||||||
|
OPI_TestDataRetrieval.ExpectsThat(ResultFile.Size() = 34432400);
|
||||||
|
BasicData.Insert("URL", FunctionParameters["S3_URL"]);
|
||||||
|
DeleteFiles(BigTempFile);
|
||||||
|
|
||||||
|
Result = OPI_S3.GetObject(Name, Bucket, BasicData);
|
||||||
|
|
||||||
|
OPI_TestDataRetrieval.WriteLog(Result, "GetObject (big, BD)", "S3");
|
||||||
|
OPI_TestDataRetrieval.Check_BinaryData(Result, 34432400);
|
||||||
|
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
#EndRegion
|
#EndRegion
|
||||||
|
|
||||||
#EndRegion
|
#EndRegion
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
//@skip-check module-structure-top-region
|
//@skip-check module-structure-top-region
|
||||||
//@skip-check module-structure-method-in-regions
|
//@skip-check module-structure-method-in-regions
|
||||||
//@skip-check wrong-string-literal-content
|
//@skip-check wrong-string-literal-content
|
||||||
|
|
||||||
#Region Internal
|
#Region Internal
|
||||||
|
|
||||||
#Region HTTPMethods
|
#Region HTTPMethods
|
||||||
@ -55,44 +54,29 @@ EndFunction
|
|||||||
|
|
||||||
#Region RequestsWithBody
|
#Region RequestsWithBody
|
||||||
|
|
||||||
Function Post(Val URL
|
Function Post(Val URL, Val Parameters = "", Val AdditionalHeaders = "", Val JSON = True, Val FullResponse = False,
|
||||||
, Val Parameters = ""
|
Val ResponseFile = Undefined) Export
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val JSON = True
|
|
||||||
, Val FullResponse = False
|
|
||||||
, Val ResponseFile = Undefined) Export
|
|
||||||
|
|
||||||
Return ExecuteRequestWithBody(URL, "POST", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile);
|
Return ExecuteRequestWithBody(URL, "POST", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile);
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function Patch(Val URL
|
Function Patch(Val URL, Val Parameters = "", Val AdditionalHeaders = "", Val JSON = True, Val FullResponse = False,
|
||||||
, Val Parameters = ""
|
Val ResponseFile = Undefined) Export
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val JSON = True
|
|
||||||
, Val FullResponse = False
|
|
||||||
, Val ResponseFile = Undefined) Export
|
|
||||||
|
|
||||||
Return ExecuteRequestWithBody(URL, "PATCH", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile);
|
Return ExecuteRequestWithBody(URL, "PATCH", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile);
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function Put(Val URL
|
Function Put(Val URL, Val Parameters = "", Val AdditionalHeaders = "", Val JSON = True, Val FullResponse = False,
|
||||||
, Val Parameters = ""
|
Val ResponseFile = Undefined) Export
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val JSON = True
|
|
||||||
, Val FullResponse = False
|
|
||||||
, Val ResponseFile = Undefined) Export
|
|
||||||
|
|
||||||
Return ExecuteRequestWithBody(URL, "PUT", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile);
|
Return ExecuteRequestWithBody(URL, "PUT", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile);
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function PostBinary(Val URL
|
Function PostBinary(Val URL, Val Body, Val AdditionalHeaders, Val FullResponse = False,
|
||||||
, Val Body
|
Val DataType = "application/octet-stream") Export
|
||||||
, Val AdditionalHeaders
|
|
||||||
, Val FullResponse = False
|
|
||||||
, Val DataType = "application/octet-stream") Export
|
|
||||||
|
|
||||||
Return ExecuteRequestWithBinaryData(URL, "POST", Body, AdditionalHeaders, FullResponse, DataType);
|
Return ExecuteRequestWithBinaryData(URL, "POST", Body, AdditionalHeaders, FullResponse, DataType);
|
||||||
|
|
||||||
@ -102,43 +86,29 @@ EndFunction
|
|||||||
|
|
||||||
#Region MultipartRequests
|
#Region MultipartRequests
|
||||||
|
|
||||||
Function PostMultipart(Val URL
|
Function PostMultipart(Val URL, Val Parameters = "", Val Files = "", Val ContentType = "image/jpeg",
|
||||||
, Val Parameters = ""
|
Val AdditionalHeaders = "", Val ResponseFile = Undefined) Export
|
||||||
, Val Files = ""
|
|
||||||
, Val ContentType = "image/jpeg"
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val ResponseFile = Undefined) Export
|
|
||||||
|
|
||||||
Return ExecuteMultipartRequest(URL, "POST", Parameters, Files, ContentType, AdditionalHeaders, ResponseFile);
|
Return ExecuteMultipartRequest(URL, "POST", Parameters, Files, ContentType, AdditionalHeaders, ResponseFile);
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function PutMultipart(Val URL
|
Function PutMultipart(Val URL, Val Parameters = "", Val Files = "", Val ContentType = "image/jpeg",
|
||||||
, Val Parameters = ""
|
Val AdditionalHeaders = "", Val ResponseFile = Undefined) Export
|
||||||
, Val Files = ""
|
|
||||||
, Val ContentType = "image/jpeg"
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val ResponseFile = Undefined) Export
|
|
||||||
|
|
||||||
Return ExecuteMultipartRequest(URL, "PUT", Parameters, Files, ContentType, AdditionalHeaders, ResponseFile);
|
Return ExecuteMultipartRequest(URL, "PUT", Parameters, Files, ContentType, AdditionalHeaders, ResponseFile);
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function PostMultipartRelated(Val URL
|
Function PostMultipartRelated(Val URL, Val JSON = "", Val Files = "", Val AdditionalHeaders = "",
|
||||||
, Val JSON = ""
|
Val ResponseFile = Undefined) Export
|
||||||
, Val Files = ""
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val ResponseFile = Undefined) Export
|
|
||||||
|
|
||||||
Return ExecuteMultipartRelatedRequest(URL, "POST", JSON, Files, AdditionalHeaders, ResponseFile);
|
Return ExecuteMultipartRelatedRequest(URL, "POST", JSON, Files, AdditionalHeaders, ResponseFile);
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function PatchMultipartRelated(Val URL
|
Function PatchMultipartRelated(Val URL, Val JSON = "", Val Files = "", Val AdditionalHeaders = "",
|
||||||
, Val JSON = ""
|
Val ResponseFile = Undefined) Export
|
||||||
, Val Files = ""
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val ResponseFile = Undefined) Export
|
|
||||||
|
|
||||||
Return ExecuteMultipartRelatedRequest(URL, "PATCH", JSON, Files, AdditionalHeaders, ResponseFile);
|
Return ExecuteMultipartRelatedRequest(URL, "PATCH", JSON, Files, AdditionalHeaders, ResponseFile);
|
||||||
|
|
||||||
@ -162,9 +132,8 @@ Procedure ProcessResponse(Response, Val FullResponse = False) Export
|
|||||||
EndIf;
|
EndIf;
|
||||||
|
|
||||||
GZip = "gzip";
|
GZip = "gzip";
|
||||||
NeedsUnpacking =
|
NeedsUnpacking = Response.Headers.Get("Content-Encoding") = GZip Or Response.Headers.Get(
|
||||||
Response.Headers.Get("Content-Encoding") = GZip
|
"content-encoding") = GZip;
|
||||||
Or Response.Headers.Get("content-encoding") = GZip;
|
|
||||||
|
|
||||||
If NeedsUnpacking Then
|
If NeedsUnpacking Then
|
||||||
Response = UnpackResponse(Response);
|
Response = UnpackResponse(Response);
|
||||||
@ -276,12 +245,8 @@ Function CreateRequestWithBody(Val Address, Val Parameters, Val AdditionalHeader
|
|||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function CreateMultipartRequest(Val Address
|
Function CreateMultipartRequest(Val Address, Val Parameters, Val Files, Val AdditionalHeaders, Val FileName,
|
||||||
, Val Parameters
|
Val ContentType) Export
|
||||||
, Val Files
|
|
||||||
, Val AdditionalHeaders
|
|
||||||
, Val FileName
|
|
||||||
, Val ContentType) Export
|
|
||||||
|
|
||||||
Boundary = StrReplace(String(New UUID), "-", "");
|
Boundary = StrReplace(String(New UUID), "-", "");
|
||||||
LineSeparator = Chars.CR + Chars.LF;
|
LineSeparator = Chars.CR + Chars.LF;
|
||||||
@ -289,13 +254,7 @@ Function CreateMultipartRequest(Val Address
|
|||||||
|
|
||||||
Request = CreateRequest(Address, AdditionalHeaders, DataType);
|
Request = CreateRequest(Address, AdditionalHeaders, DataType);
|
||||||
|
|
||||||
TextRecord = New DataWriter(FileName
|
TextRecord = New DataWriter(FileName, TextEncoding.UTF8, ByteOrder.LittleEndian, "", False, "", False);
|
||||||
, TextEncoding.UTF8
|
|
||||||
, ByteOrder.LittleEndian
|
|
||||||
, ""
|
|
||||||
, False
|
|
||||||
, ""
|
|
||||||
, False);
|
|
||||||
|
|
||||||
WriteMultipartParameters(TextRecord, Boundary, Parameters);
|
WriteMultipartParameters(TextRecord, Boundary, Parameters);
|
||||||
WriteMultipartFiles(TextRecord, Boundary, ContentType, Files);
|
WriteMultipartFiles(TextRecord, Boundary, ContentType, Files);
|
||||||
@ -316,13 +275,7 @@ Function CreateMultipartRelatedRequest(Val Address, Val Files, Val JSON, Val Add
|
|||||||
DataType = "multipart/related; boundary=" + Boundary;
|
DataType = "multipart/related; boundary=" + Boundary;
|
||||||
|
|
||||||
Request = CreateRequest(Address, AdditionalHeaders, DataType);
|
Request = CreateRequest(Address, AdditionalHeaders, DataType);
|
||||||
TextRecord = New DataWriter(FileName
|
TextRecord = New DataWriter(FileName, TextEncoding.UTF8, ByteOrder.LittleEndian, "", False, "", False);
|
||||||
, TextEncoding.UTF8
|
|
||||||
, ByteOrder.LittleEndian
|
|
||||||
, ""
|
|
||||||
, False
|
|
||||||
, ""
|
|
||||||
, False);
|
|
||||||
|
|
||||||
WriteJSONMultipart(TextRecord, Boundary, JSON);
|
WriteJSONMultipart(TextRecord, Boundary, JSON);
|
||||||
WriteRelatedFiles(TextRecord, Boundary, Files);
|
WriteRelatedFiles(TextRecord, Boundary, Files);
|
||||||
@ -361,11 +314,7 @@ Function RequestParametersToString(Val Parameters, Val SplitArrayParams = False,
|
|||||||
|
|
||||||
ParameterValue = ConvertParameterToString(CurrentValue);
|
ParameterValue = ConvertParameterToString(CurrentValue);
|
||||||
|
|
||||||
ParameterString = ParameterString
|
ParameterString = ParameterString + Parameter.Key + "=" + ParameterValue + "&";
|
||||||
+ Parameter.Key
|
|
||||||
+ "="
|
|
||||||
+ ParameterValue
|
|
||||||
+ "&";
|
|
||||||
|
|
||||||
Else
|
Else
|
||||||
|
|
||||||
@ -404,7 +353,7 @@ Function SplitURL(Val URL) Export
|
|||||||
|
|
||||||
ReturnStructure = New Structure;
|
ReturnStructure = New Structure;
|
||||||
ReturnStructure.Insert("Host" , Host);
|
ReturnStructure.Insert("Host" , Host);
|
||||||
ReturnStructure.Insert("Address" , Address);
|
ReturnStructure.Insert("Address", Address);
|
||||||
ReturnStructure.Insert("Safe" , SecureConnection);
|
ReturnStructure.Insert("Safe" , SecureConnection);
|
||||||
|
|
||||||
Return ReturnStructure;
|
Return ReturnStructure;
|
||||||
@ -429,21 +378,12 @@ Function JsonToStructure(Val Text) Export
|
|||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function JSONString(Val Data
|
Function JSONString(Val Data, Val Escaping = "None", Val LineBreaks = True, Val DoubleQuotes = True) Export
|
||||||
, Val Escaping = "None"
|
|
||||||
, Val LineBreaks = True
|
|
||||||
, Val DoubleQuotes = True) Export
|
|
||||||
|
|
||||||
LineBreak = ?(LineBreaks, JSONLineBreak.Windows, JSONLineBreak.None);
|
LineBreak = ?(LineBreaks, JSONLineBreak.Windows, JSONLineBreak.None);
|
||||||
|
|
||||||
JSONParameters = New JSONWriterSettings(LineBreak
|
JSONParameters = New JSONWriterSettings(LineBreak, " ", DoubleQuotes, JSONCharactersEscapeMode[Escaping],
|
||||||
, " "
|
False, False, False, False);
|
||||||
, DoubleQuotes
|
|
||||||
, JSONCharactersEscapeMode[Escaping]
|
|
||||||
, False
|
|
||||||
, False
|
|
||||||
, False
|
|
||||||
, False);
|
|
||||||
|
|
||||||
Try
|
Try
|
||||||
|
|
||||||
@ -571,17 +511,40 @@ Function CollectionFieldExist(Val Collection, Val Field) Export
|
|||||||
|
|
||||||
CollectionType = TypeOf(Collection);
|
CollectionType = TypeOf(Collection);
|
||||||
|
|
||||||
If CollectionType = Type("Structure") Then
|
IsStructure = CollectionType = Type("Structure");
|
||||||
|
IsMap = CollectionType = Type("Map");
|
||||||
|
ThisIsCollection = IsStructure Or IsMap;
|
||||||
|
|
||||||
|
If StrFind(Field, ".") And ThisIsCollection Then
|
||||||
|
|
||||||
|
FieldParts = StrSplit(Field, ".");
|
||||||
|
CurrentField = FieldParts[0];
|
||||||
|
|
||||||
|
If Not CollectionFieldExist(Collection, CurrentField) Then
|
||||||
|
|
||||||
|
Return False;
|
||||||
|
|
||||||
|
Else
|
||||||
|
|
||||||
|
FieldParts.Delete(0);
|
||||||
|
NextCollection = Collection[CurrentField];
|
||||||
|
NextField = StrConcat(FieldParts, ".");
|
||||||
|
|
||||||
|
Return CollectionFieldExist(NextCollection, NextField);
|
||||||
|
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
ElsIf IsStructure Then
|
||||||
|
|
||||||
Return Collection.Property(Field);
|
Return Collection.Property(Field);
|
||||||
|
|
||||||
ElsIf CollectionType = Type("Map") Then
|
ElsIf IsMap Then
|
||||||
|
|
||||||
Return Collection[Field] <> Undefined;
|
Return Collection[Field] <> Undefined;
|
||||||
|
|
||||||
Else
|
Else
|
||||||
|
|
||||||
Raise "The specified value is not a valid collection!";
|
Return False;
|
||||||
|
|
||||||
EndIf;
|
EndIf;
|
||||||
|
|
||||||
@ -676,7 +639,7 @@ Function IsOneScript() Export
|
|||||||
// BSLLS:UnusedLocalVariable-off
|
// BSLLS:UnusedLocalVariable-off
|
||||||
|
|
||||||
//@skip-check module-unused-local-variable
|
//@skip-check module-unused-local-variable
|
||||||
Check = New OpenSSLSecureConnection();
|
Check = New OpenSSLSecureConnection;
|
||||||
|
|
||||||
// BSLLS:UnusedLocalVariable-on
|
// BSLLS:UnusedLocalVariable-on
|
||||||
|
|
||||||
@ -778,9 +741,7 @@ EndFunction
|
|||||||
|
|
||||||
Function RelevantNodeType(Val NodeType)
|
Function RelevantNodeType(Val NodeType)
|
||||||
|
|
||||||
Return NodeType = XMLNodeType.StartElement
|
Return NodeType = XMLNodeType.StartElement Or NodeType = XMLNodeType.EndElement Or NodeType = XMLNodeType.Text;
|
||||||
Or NodeType = XMLNodeType.EndElement
|
|
||||||
Or NodeType = XMLNodeType.Text;
|
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
@ -827,7 +788,7 @@ EndProcedure
|
|||||||
Procedure RemoveEmptyCollectionFields(Collection) Export
|
Procedure RemoveEmptyCollectionFields(Collection) Export
|
||||||
|
|
||||||
CollectionType = TypeOf(Collection);
|
CollectionType = TypeOf(Collection);
|
||||||
OutputCollection = New(CollectionType);
|
OutputCollection = New (CollectionType);
|
||||||
|
|
||||||
If CollectionType = Type("Map") Or CollectionType = Type("Structure") Then
|
If CollectionType = Type("Map") Or CollectionType = Type("Structure") Then
|
||||||
|
|
||||||
@ -923,13 +884,8 @@ EndProcedure
|
|||||||
|
|
||||||
#Region Private
|
#Region Private
|
||||||
|
|
||||||
Function ExecuteRequestWithBody(Val URL
|
Function ExecuteRequestWithBody(Val URL, Val View, Val Parameters = "", Val AdditionalHeaders = "", Val JSON = True,
|
||||||
, Val View
|
Val FullResponse = False, Val ResponseFile = Undefined)
|
||||||
, Val Parameters = ""
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val JSON = True
|
|
||||||
, Val FullResponse = False
|
|
||||||
, Val ResponseFile = Undefined)
|
|
||||||
|
|
||||||
If Not ValueIsFilled(Parameters) Then
|
If Not ValueIsFilled(Parameters) Then
|
||||||
Parameters = New Structure;
|
Parameters = New Structure;
|
||||||
@ -948,12 +904,8 @@ Function ExecuteRequestWithBody(Val URL
|
|||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function ExecuteRequestWithBinaryData(Val URL
|
Function ExecuteRequestWithBinaryData(Val URL, Val View, Val Data, Val AdditionalHeaders, Val FullResponse,
|
||||||
, Val View
|
Val DataType)
|
||||||
, Val Data
|
|
||||||
, Val AdditionalHeaders
|
|
||||||
, Val FullResponse
|
|
||||||
, Val DataType)
|
|
||||||
|
|
||||||
URLStructure = SplitURL(URL);
|
URLStructure = SplitURL(URL);
|
||||||
Host = URLStructure["Host"];
|
Host = URLStructure["Host"];
|
||||||
@ -973,11 +925,8 @@ Function ExecuteRequestWithBinaryData(Val URL
|
|||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function ExecuteRequestWithoutBody(Val URL
|
Function ExecuteRequestWithoutBody(Val URL, Val View, Val Parameters = "", Val AdditionalHeaders = "",
|
||||||
, Val View
|
Val ResponseFile = Undefined)
|
||||||
, Val Parameters = ""
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val ResponseFile = Undefined)
|
|
||||||
|
|
||||||
If Not ValueIsFilled(Parameters) Then
|
If Not ValueIsFilled(Parameters) Then
|
||||||
Parameters = New Structure;
|
Parameters = New Structure;
|
||||||
@ -997,13 +946,8 @@ Function ExecuteRequestWithoutBody(Val URL
|
|||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function ExecuteMultipartRequest(Val URL
|
Function ExecuteMultipartRequest(Val URL, Val View, Val Parameters = "", Val Files = "",
|
||||||
, Val View
|
Val ContentType = "image/jpeg", Val AdditionalHeaders = "", Val ResponseFile = Undefined)
|
||||||
, Val Parameters = ""
|
|
||||||
, Val Files = ""
|
|
||||||
, Val ContentType = "image/jpeg"
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val ResponseFile = Undefined)
|
|
||||||
|
|
||||||
If Not ValueIsFilled(Parameters) Then
|
If Not ValueIsFilled(Parameters) Then
|
||||||
Parameters = New Structure;
|
Parameters = New Structure;
|
||||||
@ -1032,12 +976,8 @@ Function ExecuteMultipartRequest(Val URL
|
|||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function ExecuteMultipartRelatedRequest(Val URL
|
Function ExecuteMultipartRelatedRequest(Val URL, Val View, Val JSON = "", Val Files = "", Val AdditionalHeaders = "",
|
||||||
, Val View
|
Val ResponseFile = Undefined)
|
||||||
, Val JSON = ""
|
|
||||||
, Val Files = ""
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val ResponseFile = Undefined)
|
|
||||||
|
|
||||||
URLStructure = SplitURL(URL);
|
URLStructure = SplitURL(URL);
|
||||||
Host = URLStructure["Host"];
|
Host = URLStructure["Host"];
|
||||||
@ -1064,9 +1004,8 @@ Function ThisIsRedirection(Val Response)
|
|||||||
Redirection = 300;
|
Redirection = 300;
|
||||||
Error = 400;
|
Error = 400;
|
||||||
|
|
||||||
ThisIsRedirection = Response.StatusCode >= Redirection
|
ThisIsRedirection = Response.StatusCode >= Redirection And Response.StatusCode < Error And ValueIsFilled(
|
||||||
And Response.StatusCode < Error
|
Response.Headers["Location"]);
|
||||||
And ValueIsFilled(Response.Headers["Location"]);
|
|
||||||
|
|
||||||
Return ThisIsRedirection;
|
Return ThisIsRedirection;
|
||||||
|
|
||||||
@ -1162,9 +1101,8 @@ EndFunction
|
|||||||
|
|
||||||
Procedure SetRequestBody(Request, Val Parameters, Val JSON)
|
Procedure SetRequestBody(Request, Val Parameters, Val JSON)
|
||||||
|
|
||||||
Collection = TypeOf(Parameters) = Type("Structure")
|
Collection = TypeOf(Parameters) = Type("Structure") Or TypeOf(Parameters) = Type("Map") Or TypeOf(Parameters)
|
||||||
Or TypeOf(Parameters) = Type("Map")
|
= Type("Array");
|
||||||
Or TypeOf(Parameters) = Type("Array");
|
|
||||||
|
|
||||||
If JSON Then
|
If JSON Then
|
||||||
|
|
||||||
@ -1196,8 +1134,7 @@ Procedure WriteMultipartParameters(TextRecord, Val Boundary, Val Parameters)
|
|||||||
|
|
||||||
For Each Parameter In Parameters Do
|
For Each Parameter In Parameters Do
|
||||||
|
|
||||||
If Parameter.Value = Undefined
|
If Parameter.Value = Undefined Or Parameter.Value = Null Then
|
||||||
Or Parameter.Value = NULL Then
|
|
||||||
Continue;
|
Continue;
|
||||||
EndIf;
|
EndIf;
|
||||||
|
|
||||||
@ -1206,8 +1143,7 @@ Procedure WriteMultipartParameters(TextRecord, Val Boundary, Val Parameters)
|
|||||||
TextRecord.WriteLine(LineSeparator);
|
TextRecord.WriteLine(LineSeparator);
|
||||||
TextRecord.WriteLine(LineSeparator);
|
TextRecord.WriteLine(LineSeparator);
|
||||||
|
|
||||||
If TypeOf(Parameter.Value) = Type("String")
|
If TypeOf(Parameter.Value) = Type("String") Or TypeOf(Parameter.Value) = Type("Number") Then
|
||||||
Or TypeOf(Parameter.Value) = Type("Number") Then
|
|
||||||
|
|
||||||
ValueAsString = NumberToString(Parameter.Value);
|
ValueAsString = NumberToString(Parameter.Value);
|
||||||
TextRecord.WriteLine(ValueAsString);
|
TextRecord.WriteLine(ValueAsString);
|
||||||
@ -1241,10 +1177,7 @@ Procedure WriteMultipartFiles(TextRecord, Val Boundary, Val ContentType, Val Fil
|
|||||||
FileName = DataStructure["FileName"];
|
FileName = DataStructure["FileName"];
|
||||||
|
|
||||||
TextRecord.WriteLine("--" + boundary + LineSeparator);
|
TextRecord.WriteLine("--" + boundary + LineSeparator);
|
||||||
TextRecord.WriteLine("Content-Disposition: form-data; name="""
|
TextRecord.WriteLine("Content-Disposition: form-data; name=""" + FieldName + """; filename=""" + FileName
|
||||||
+ FieldName
|
|
||||||
+ """; filename="""
|
|
||||||
+ FileName
|
|
||||||
+ """");
|
+ """");
|
||||||
TextRecord.WriteLine(LineSeparator);
|
TextRecord.WriteLine(LineSeparator);
|
||||||
|
|
||||||
@ -1351,7 +1284,7 @@ Procedure RemoveEmptyKeyValues(Val Collection, OutputCollection)
|
|||||||
|
|
||||||
For Each CollectionItem In Collection Do
|
For Each CollectionItem In Collection Do
|
||||||
|
|
||||||
If Not CollectionItem.Value = Undefined And Not CollectionItem.Value = NULL Then
|
If Not CollectionItem.Value = Undefined And Not CollectionItem.Value = Null Then
|
||||||
OutputCollection.Insert(CollectionItem.Key, CollectionItem.Value);
|
OutputCollection.Insert(CollectionItem.Key, CollectionItem.Value);
|
||||||
EndIf;
|
EndIf;
|
||||||
|
|
||||||
@ -1363,7 +1296,7 @@ Procedure RemoveEmptyArrayItems(Val Collection, OutputCollection)
|
|||||||
|
|
||||||
For Each CollectionItem In Collection Do
|
For Each CollectionItem In Collection Do
|
||||||
|
|
||||||
If Not CollectionItem = Undefined And Not CollectionItem = NULL Then
|
If Not CollectionItem = Undefined And Not CollectionItem = Null Then
|
||||||
OutputCollection.Add(CollectionItem);
|
OutputCollection.Add(CollectionItem);
|
||||||
EndIf;
|
EndIf;
|
||||||
|
|
||||||
@ -1454,11 +1387,7 @@ Function ReadGZip(CompressedData) Export
|
|||||||
DataReader.Skip(GZipPrefixSize);
|
DataReader.Skip(GZipPrefixSize);
|
||||||
CompressedDataSize = DataReader.SourceStream().Size() - GZipPrefixSize - GZipPostfixSize;
|
CompressedDataSize = DataReader.SourceStream().Size() - GZipPrefixSize - GZipPostfixSize;
|
||||||
|
|
||||||
ZipStream = New MemoryStream(SizeLFH
|
ZipStream = New MemoryStream(SizeLFH + CompressedDataSize + SizeDD + SizeCDH + SizeESD);
|
||||||
+ CompressedDataSize
|
|
||||||
+ SizeDD
|
|
||||||
+ SizeCDH
|
|
||||||
+ SizeESD);
|
|
||||||
|
|
||||||
DataWriter = New DataWriter(ZipStream);
|
DataWriter = New DataWriter(ZipStream);
|
||||||
DataWriter.WriteBinaryDataBuffer(ZipLFH());
|
DataWriter.WriteBinaryDataBuffer(ZipLFH());
|
||||||
|
@ -77,13 +77,17 @@ EndFunction
|
|||||||
// Parameters:
|
// Parameters:
|
||||||
// Method - String - HTTP method - method
|
// Method - String - HTTP method - method
|
||||||
// BasicData - Structure of KeyAndValue - Basic request data (with full URL). See GetBasicDataStructure - basic
|
// BasicData - Structure of KeyAndValue - Basic request data (with full URL). See GetBasicDataStructure - basic
|
||||||
|
// ExpectedBinary - Boolean - Disables an attempt to convert the response to JSON - binary
|
||||||
// Headers - Map Of KeyAndValue - Additional request headers, if necessary - headers
|
// Headers - Map Of KeyAndValue - Additional request headers, if necessary - headers
|
||||||
//
|
//
|
||||||
// Returns:
|
// Returns:
|
||||||
// Structure of KeyAndValue - serialized JSON response from storage
|
// Structure of KeyAndValue - serialized JSON response from storage
|
||||||
Function SendRequestWithoutBody(Val Method, Val BasicData, Val Headers = Undefined) Export
|
Function SendRequestWithoutBody(Val Method
|
||||||
|
, Val BasicData
|
||||||
|
, Val ExpectedBinary = False
|
||||||
|
, Val Headers = Undefined) Export
|
||||||
|
|
||||||
Response = SendRequest(Method, BasicData, , Headers);
|
Response = SendRequest(Method, BasicData, , ExpectedBinary, Headers);
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
@ -95,13 +99,18 @@ EndFunction
|
|||||||
// Method - String - HTTP method - method
|
// Method - String - HTTP method - method
|
||||||
// BasicData - Structure of KeyAndValue - Basic request data (with full URL). See GetBasicDataStructure - basic
|
// BasicData - Structure of KeyAndValue - Basic request data (with full URL). See GetBasicDataStructure - basic
|
||||||
// Body - String, BinaryData - Binary data or file of request body data - body
|
// Body - String, BinaryData - Binary data or file of request body data - body
|
||||||
|
// ExpectedBinary - Boolean - Disables an attempt to convert the response to JSON - binary
|
||||||
// Headers - Map Of KeyAndValue - Additional request headers, if necessary - headers
|
// Headers - Map Of KeyAndValue - Additional request headers, if necessary - headers
|
||||||
//
|
//
|
||||||
// Returns:
|
// Returns:
|
||||||
// Structure of KeyAndValue - serialized JSON response from storage
|
// Structure of KeyAndValue - serialized JSON response from storage
|
||||||
Function SendRequestWithBody(Val Method, Val BasicData, Val Body, Val Headers = Undefined) Export
|
Function SendRequestWithBody(Val Method
|
||||||
|
, Val BasicData
|
||||||
|
, Val Body
|
||||||
|
, Val ExpectedBinary = False
|
||||||
|
, Val Headers = Undefined) Export
|
||||||
|
|
||||||
Response = SendRequest(Method, BasicData, Body, Headers);
|
Response = SendRequest(Method, BasicData, Body, ExpectedBinary, Headers);
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
@ -216,7 +225,7 @@ Function PutBucketEncryption(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithBody("PUT", BasicData, XmlConfig, Headers);
|
Response = SendRequestWithBody("PUT", BasicData, XmlConfig, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -248,7 +257,7 @@ Function GetBucketEncryption(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("GET", BasicData, Headers);
|
Response = SendRequestWithoutBody("GET", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -280,7 +289,7 @@ Function DeleteBucketEncryption(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("DELETE", BasicData, Headers);
|
Response = SendRequestWithoutBody("DELETE", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -318,7 +327,7 @@ Function PutBucketTagging(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithBody("PUT", BasicData, TagsXML, Headers);
|
Response = SendRequestWithBody("PUT", BasicData, TagsXML, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -349,7 +358,7 @@ Function GetBucketTagging(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("GET", BasicData, Headers);
|
Response = SendRequestWithoutBody("GET", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -380,7 +389,7 @@ Function DeleteBucketTagging(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("DELETE", BasicData, Headers);
|
Response = SendRequestWithoutBody("DELETE", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -419,7 +428,7 @@ Function PutBucketVersioning(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithBody("PUT", BasicData, TagsXML, Headers);
|
Response = SendRequestWithBody("PUT", BasicData, TagsXML, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -450,7 +459,7 @@ Function GetBucketVersioning(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("GET", BasicData, Headers);
|
Response = SendRequestWithoutBody("GET", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -488,7 +497,7 @@ Function ListBuckets(Val BasicData
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("GET", BasicData, Headers);
|
Response = SendRequestWithoutBody("GET", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -527,7 +536,7 @@ Function PutObject(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequest("PUT", BasicData, Entity, Headers);
|
Response = SendRequest("PUT", BasicData, Entity, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -570,13 +579,68 @@ Function HeadObject(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithBody("HEAD", BasicData, Headers);
|
Response = SendRequestWithoutBody("HEAD", BasicData, , Headers);
|
||||||
Response["response"] = New Structure;
|
Response["response"] = New Structure;
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
|
// Get object
|
||||||
|
// Gets the contents of the object from the bucket
|
||||||
|
//
|
||||||
|
// Note
|
||||||
|
// Method at AWS documentation: [GetObjectAttributes](@docs.aws.amazon.com/AmazonS3/latest/API/API_GetObjectAttributes.html)
|
||||||
|
// You can use the `ChunkSize` field in the basic data to specify the minimum file and chunk size for a chunked upload
|
||||||
|
// For example, ChunkSize=X means that all files larger than X (in bytes) will be downloaded in chunks, where one chunk will be of size X.
|
||||||
|
// Chunk upload is used for large files. Default ChunkSize - 20000000 bytes (20 MB)
|
||||||
|
//
|
||||||
|
// Parameters:
|
||||||
|
// Name - String - Name of the object in the bucket - name
|
||||||
|
// Bucket - String - Name of the bucket in which the object is stored - bucket
|
||||||
|
// BasicData - Structure of KeyAndValue - Basic request data. See GetBasicDataStructure - basic
|
||||||
|
// Directory - Boolean - True > Directory Bucket, False > General Purpose Bucket - dir
|
||||||
|
// Version - String - Token for receiving a specific version of an object - ver
|
||||||
|
// Headers - Map Of KeyAndValue - Additional request headers, if necessary - headers
|
||||||
|
// SavePath - String - Path to directly write a file to disk - out
|
||||||
|
//
|
||||||
|
// Returns:
|
||||||
|
// Structure of KeyAndValue - serialized JSON response from storage
|
||||||
|
Function GetObject(Val Name
|
||||||
|
, Val Bucket
|
||||||
|
, Val BasicData
|
||||||
|
, Val Version = ""
|
||||||
|
, Val Headers = Undefined
|
||||||
|
, Val SavePath = "") Export
|
||||||
|
|
||||||
|
If OPI_Tools.CollectionFieldExists(BasicData, "ChunkSize") Then
|
||||||
|
MaxSize = BasicData["ChunkSize"];
|
||||||
|
Else
|
||||||
|
MaxSize = 20000000;
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
ObjectInfo = HeadObject(Name, Bucket, BasicData, Version);
|
||||||
|
|
||||||
|
If Not OPI_Tools.CollectionFieldExists(ObjectInfo, "headers.Content-Length") Then
|
||||||
|
Return ObjectInfo;
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
ObjectSize = ObjectInfo["headers"]["Content-Length"];
|
||||||
|
|
||||||
|
OPI_TypeConversion.GetNumber(MaxSize);
|
||||||
|
OPI_TypeConversion.GetNumber(ObjectSize);
|
||||||
|
|
||||||
|
If ObjectSize > MaxSize Then
|
||||||
|
Sizes = New Structure("object,chunk", ObjectSize, MaxSize);
|
||||||
|
Response = GetObjectInChunks(BasicData, Headers, SavePath, Sizes);
|
||||||
|
Else
|
||||||
|
Response = GetFullObject(BasicData, Headers, SavePath);
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
Return Response;
|
||||||
|
|
||||||
|
EndFunction
|
||||||
|
|
||||||
// Delete object
|
// Delete object
|
||||||
// Removes the object from the bucket
|
// Removes the object from the bucket
|
||||||
//
|
//
|
||||||
@ -613,7 +677,7 @@ Function DeleteObject(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithBody("DELETE", BasicData, Headers);
|
Response = SendRequestWithoutBody("DELETE", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -692,7 +756,7 @@ Function PutObjectTagging(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithBody("PUT", BasicData, TagsXML, Headers);
|
Response = SendRequestWithBody("PUT", BasicData, TagsXML, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -732,7 +796,7 @@ Function GetObjectTagging(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("GET", BasicData, Headers);
|
Response = SendRequestWithoutBody("GET", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -772,7 +836,7 @@ Function DeleteObjectTagging(Val Name
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("DELETE", BasicData, Headers);
|
Response = SendRequestWithoutBody("DELETE", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -811,7 +875,7 @@ Function ListObjects(Val Bucket
|
|||||||
URL = URL + OPI_Tools.RequestParametersToString(Parameters);
|
URL = URL + OPI_Tools.RequestParametersToString(Parameters);
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("GET", BasicData, Headers);
|
Response = SendRequestWithoutBody("GET", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -850,7 +914,7 @@ Function ListObjectVersions(Val Bucket
|
|||||||
URL = URL + OPI_Tools.RequestParametersToString(Parameters, , False);
|
URL = URL + OPI_Tools.RequestParametersToString(Parameters, , False);
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody("GET", BasicData, Headers);
|
Response = SendRequestWithoutBody("GET", BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -1140,7 +1204,11 @@ EndProcedure
|
|||||||
|
|
||||||
#Region Miscellaneous
|
#Region Miscellaneous
|
||||||
|
|
||||||
Function SendRequest(Val Method, Val BasicData, Val Body = Undefined, Val Headers = Undefined)
|
Function SendRequest(Val Method
|
||||||
|
, Val BasicData
|
||||||
|
, Val Body = Undefined
|
||||||
|
, Val ExpectedBinary = False
|
||||||
|
, Val Headers = Undefined)
|
||||||
|
|
||||||
CheckBasicData(BasicData);
|
CheckBasicData(BasicData);
|
||||||
|
|
||||||
@ -1164,7 +1232,7 @@ Function SendRequest(Val Method, Val BasicData, Val Body = Undefined, Val Header
|
|||||||
Request.Headers.Insert("Authorization", AuthorizationHeader);
|
Request.Headers.Insert("Authorization", AuthorizationHeader);
|
||||||
|
|
||||||
Response = OPI_Tools.ExecuteRequest(Request, Connection, Method, , True);
|
Response = OPI_Tools.ExecuteRequest(Request, Connection, Method, , True);
|
||||||
Response = FormResponse(Response);
|
Response = FormResponse(Response, ExpectedBinary);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
@ -1177,12 +1245,122 @@ Function BucketManagment(Val Name, Val BasicData, Val Directory, Val Method, Val
|
|||||||
|
|
||||||
BasicData.Insert("URL", URL);
|
BasicData.Insert("URL", URL);
|
||||||
|
|
||||||
Response = SendRequestWithoutBody(Method, BasicData, Headers);
|
Response = SendRequestWithoutBody(Method, BasicData, , Headers);
|
||||||
|
|
||||||
Return Response;
|
Return Response;
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
|
Function GetObjectInChunks(Val BasicData
|
||||||
|
, Val Headers
|
||||||
|
, Val SavePath
|
||||||
|
, Val Sizes)
|
||||||
|
|
||||||
|
TotalSize = Sizes["object"];
|
||||||
|
ChunkSize = Sizes["chunk"];
|
||||||
|
HeaderTemplate = "bytes=%1-%2";
|
||||||
|
ChunkStart = 0;
|
||||||
|
|
||||||
|
HeadersArray = New Array;
|
||||||
|
|
||||||
|
WHile ChunkStart < TotalSize - ChunkSize Do
|
||||||
|
|
||||||
|
ChunkEnd = ChunkStart + ChunkSize - 1;
|
||||||
|
|
||||||
|
StartStr = OPI_Tools.NumberToString(ChunkStart);
|
||||||
|
EndStr = OPI_Tools.NumberToString(ChunkEnd);
|
||||||
|
|
||||||
|
Title = StrTemplate(HeaderTemplate, StartStr, EndStr);
|
||||||
|
HeadersArray.Add(New Structure("Header,Position", Title, EndStr));
|
||||||
|
|
||||||
|
ChunkStart = ChunkEnd + 1;
|
||||||
|
|
||||||
|
EndDo;
|
||||||
|
|
||||||
|
If Not ChunkStart = TotalSize Then
|
||||||
|
|
||||||
|
Title = "bytes=" + OPI_Tools.NumberToString(ChunkStart) + "-";
|
||||||
|
|
||||||
|
DataStructure = New Structure("Header,Position", Title, TotalSize);
|
||||||
|
HeadersArray.Add(DataStructure);
|
||||||
|
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
If ValueIsFilled(SavePath) Then
|
||||||
|
StreamOfFile = New FileStream(SavePath, FileOpenMode.Create);
|
||||||
|
Else
|
||||||
|
StreamOfFile = New MemoryStream();
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
FileWriter = New DataWriter(StreamOfFile);
|
||||||
|
|
||||||
|
For Each CurrentSet In HeadersArray Do
|
||||||
|
|
||||||
|
For N = 1 To 3 Do
|
||||||
|
|
||||||
|
Try
|
||||||
|
|
||||||
|
ChunkHeader = CurrentSet["Title"];
|
||||||
|
CurrentPosition = CurrentSet["Item"];
|
||||||
|
|
||||||
|
SourceHeader = New Map();
|
||||||
|
SourceHeader.Insert("Range", ChunkHeader);
|
||||||
|
AddAdditionalHeaders(Headers, SourceHeader);
|
||||||
|
|
||||||
|
InterimResult = GetFullObject(BasicData, SourceHeader);
|
||||||
|
FileWriter.Write(InterimResult);
|
||||||
|
|
||||||
|
// !OInt KB = 1024;
|
||||||
|
// !OInt MB = KB * KB;
|
||||||
|
// !OInt Message(OPI_Tools.ProgressInfo(CurrentPosition, TotalSize, "MB", MB));
|
||||||
|
|
||||||
|
// !OInt RunGarbageCollection();
|
||||||
|
// !OInt FreeObject(InterimResult);
|
||||||
|
|
||||||
|
Break;
|
||||||
|
|
||||||
|
Except
|
||||||
|
|
||||||
|
If N = 3 Then
|
||||||
|
// !OInt Message(ErrorDescription());
|
||||||
|
Break;
|
||||||
|
Else
|
||||||
|
// !OInt Message("Chunk upload error " + String(N) + "/3");
|
||||||
|
Continue;
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
EndTry;
|
||||||
|
|
||||||
|
EndDo;
|
||||||
|
|
||||||
|
EndDo;
|
||||||
|
|
||||||
|
FileWriter.Close();
|
||||||
|
|
||||||
|
If TypeOf(StreamOfFile) = Type("MemoryStream") Then
|
||||||
|
Return StreamOfFile.CloseAndGetBinaryData();
|
||||||
|
Else
|
||||||
|
StreamOfFile.Close();
|
||||||
|
Return New Structure("file", SavePath);
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
EndFunction
|
||||||
|
|
||||||
|
Function GetFullObject(Val BasicData
|
||||||
|
, Val Headers
|
||||||
|
, Val SavePath = "")
|
||||||
|
|
||||||
|
Response = SendRequestWithoutBody("GET", BasicData, True, Headers);
|
||||||
|
|
||||||
|
If ValueIsFilled(SavePath) Then
|
||||||
|
Response.Write(SavePath);
|
||||||
|
Return New Structure("file", SavePath);
|
||||||
|
Else
|
||||||
|
Return Response;
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
EndFunction
|
||||||
|
|
||||||
Function FormResponse(Val Response, Val ExpectedBinary = False)
|
Function FormResponse(Val Response, Val ExpectedBinary = False)
|
||||||
|
|
||||||
Status = Response.StatusCode;
|
Status = Response.StatusCode;
|
||||||
|
@ -2155,6 +2155,7 @@ Procedure AWS_ObjectsManagment() Export
|
|||||||
S3_DeleteObjectTagging(TestParameters);
|
S3_DeleteObjectTagging(TestParameters);
|
||||||
S3_ListObjects(TestParameters);
|
S3_ListObjects(TestParameters);
|
||||||
S3_ListObjectVersions(TestParameters);
|
S3_ListObjectVersions(TestParameters);
|
||||||
|
S3_GetObject(TestParameters);
|
||||||
S3_DeleteObject(TestParameters);
|
S3_DeleteObject(TestParameters);
|
||||||
S3_DeleteBucket(TestParameters);
|
S3_DeleteBucket(TestParameters);
|
||||||
|
|
||||||
@ -15053,6 +15054,16 @@ Procedure S3_PutObject(FunctionParameters)
|
|||||||
|
|
||||||
OPI_TestDataRetrieval.WriteLog(Result, "PutObject", "S3");
|
OPI_TestDataRetrieval.WriteLog(Result, "PutObject", "S3");
|
||||||
OPI_TestDataRetrieval.Check_S3Success(Result);
|
OPI_TestDataRetrieval.Check_S3Success(Result);
|
||||||
|
BasicData.Insert("URL", FunctionParameters["S3_URL"]);
|
||||||
|
|
||||||
|
Bucket = "opi-dirbucket3";
|
||||||
|
Result = OPI_S3.PutObject(Name, Bucket, Entity, BasicData);
|
||||||
|
|
||||||
|
OPI_TestDataRetrieval.WriteLog(Result, "PutObject (DB)", "S3");
|
||||||
|
OPI_TestDataRetrieval.Check_S3Success(Result);
|
||||||
|
BasicData.Insert("URL", FunctionParameters["S3_URL"]);
|
||||||
|
|
||||||
|
OPI_S3.DeleteObject(Name, Bucket, BasicData);
|
||||||
|
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
@ -15232,6 +15243,60 @@ Procedure S3_ListObjectVersions(FunctionParameters)
|
|||||||
|
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure S3_GetObject(FunctionParameters)
|
||||||
|
|
||||||
|
Image = FunctionParameters["Picture"]; // SKIP
|
||||||
|
OPI_TypeConversion.GetBinaryData(Image); // SKIP
|
||||||
|
RequiredSize = Image.Size(); // SKIP
|
||||||
|
|
||||||
|
URL = FunctionParameters["S3_URL"];
|
||||||
|
AccessKey = FunctionParameters["S3_AccessKey"];
|
||||||
|
SecretKey = FunctionParameters["S3_SecretKey"];
|
||||||
|
Region = "BTC";
|
||||||
|
|
||||||
|
BasicData = OPI_S3.GetBasicDataStructure(URL, AccessKey, SecretKey, Region);
|
||||||
|
|
||||||
|
Name = "picture.jpg";
|
||||||
|
Bucket = "opi-gpbucket3";
|
||||||
|
|
||||||
|
Result = OPI_S3.GetObject(Name, Bucket, BasicData);
|
||||||
|
|
||||||
|
OPI_TestDataRetrieval.WriteLog(Result, "GetObject", "S3"); // SKIP
|
||||||
|
OPI_TestDataRetrieval.Check_BinaryData(Result, RequiredSize); // SKIP
|
||||||
|
BasicData.Insert("URL", FunctionParameters["S3_URL"]); // SKIP
|
||||||
|
|
||||||
|
TempFile = GetTempFileName();
|
||||||
|
BasicData.Insert("ChunkSize", 200000);
|
||||||
|
|
||||||
|
Result = OPI_S3.GetObject(Name, Bucket, BasicData, , , TempFile);
|
||||||
|
|
||||||
|
// END
|
||||||
|
|
||||||
|
OPI_TestDataRetrieval.WriteLog(Result, "GetObject (file)", "S3");
|
||||||
|
ResultFile = New File(Result["file"]);
|
||||||
|
OPI_TestDataRetrieval.ExpectsThat(ResultFile.Size() = RequiredSize);
|
||||||
|
BasicData.Insert("URL", FunctionParameters["S3_URL"]);
|
||||||
|
DeleteFiles(TempFile);
|
||||||
|
|
||||||
|
Name = "bigfile.exe";
|
||||||
|
Bucket = "newbucket2";
|
||||||
|
|
||||||
|
BigTempFile = GetTempFileName();
|
||||||
|
Result = OPI_S3.GetObject(Name, Bucket, BasicData, , , BigTempFile);
|
||||||
|
ResultFile = New File(Result["file"]);
|
||||||
|
|
||||||
|
OPI_TestDataRetrieval.WriteLog(Result, "GetObject (big, file)", "S3");
|
||||||
|
OPI_TestDataRetrieval.ExpectsThat(ResultFile.Size() = 34432400);
|
||||||
|
BasicData.Insert("URL", FunctionParameters["S3_URL"]);
|
||||||
|
DeleteFiles(BigTempFile);
|
||||||
|
|
||||||
|
Result = OPI_S3.GetObject(Name, Bucket, BasicData);
|
||||||
|
|
||||||
|
OPI_TestDataRetrieval.WriteLog(Result, "GetObject (big, BD)", "S3");
|
||||||
|
OPI_TestDataRetrieval.Check_BinaryData(Result, 34432400);
|
||||||
|
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
#EndRegion
|
#EndRegion
|
||||||
|
|
||||||
#EndRegion
|
#EndRegion
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
//@skip-check module-structure-top-region
|
//@skip-check module-structure-top-region
|
||||||
//@skip-check module-structure-method-in-regions
|
//@skip-check module-structure-method-in-regions
|
||||||
//@skip-check wrong-string-literal-content
|
//@skip-check wrong-string-literal-content
|
||||||
|
|
||||||
#Region Internal
|
#Region Internal
|
||||||
|
|
||||||
#Region HTTPMethods
|
#Region HTTPMethods
|
||||||
@ -55,44 +54,29 @@ EndFunction
|
|||||||
|
|
||||||
#Region RequestsWithBody
|
#Region RequestsWithBody
|
||||||
|
|
||||||
Function Post(Val URL
|
Function Post(Val URL, Val Parameters = "", Val AdditionalHeaders = "", Val JSON = True, Val FullResponse = False,
|
||||||
, Val Parameters = ""
|
Val ResponseFile = Undefined) Export
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val JSON = True
|
|
||||||
, Val FullResponse = False
|
|
||||||
, Val ResponseFile = Undefined) Export
|
|
||||||
|
|
||||||
Return ExecuteRequestWithBody(URL, "POST", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile);
|
Return ExecuteRequestWithBody(URL, "POST", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile);
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function Patch(Val URL
|
Function Patch(Val URL, Val Parameters = "", Val AdditionalHeaders = "", Val JSON = True, Val FullResponse = False,
|
||||||
, Val Parameters = ""
|
Val ResponseFile = Undefined) Export
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val JSON = True
|
|
||||||
, Val FullResponse = False
|
|
||||||
, Val ResponseFile = Undefined) Export
|
|
||||||
|
|
||||||
Return ExecuteRequestWithBody(URL, "PATCH", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile);
|
Return ExecuteRequestWithBody(URL, "PATCH", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile);
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function Put(Val URL
|
Function Put(Val URL, Val Parameters = "", Val AdditionalHeaders = "", Val JSON = True, Val FullResponse = False,
|
||||||
, Val Parameters = ""
|
Val ResponseFile = Undefined) Export
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val JSON = True
|
|
||||||
, Val FullResponse = False
|
|
||||||
, Val ResponseFile = Undefined) Export
|
|
||||||
|
|
||||||
Return ExecuteRequestWithBody(URL, "PUT", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile);
|
Return ExecuteRequestWithBody(URL, "PUT", Parameters, AdditionalHeaders, JSON, FullResponse, ResponseFile);
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function PostBinary(Val URL
|
Function PostBinary(Val URL, Val Body, Val AdditionalHeaders, Val FullResponse = False,
|
||||||
, Val Body
|
Val DataType = "application/octet-stream") Export
|
||||||
, Val AdditionalHeaders
|
|
||||||
, Val FullResponse = False
|
|
||||||
, Val DataType = "application/octet-stream") Export
|
|
||||||
|
|
||||||
Return ExecuteRequestWithBinaryData(URL, "POST", Body, AdditionalHeaders, FullResponse, DataType);
|
Return ExecuteRequestWithBinaryData(URL, "POST", Body, AdditionalHeaders, FullResponse, DataType);
|
||||||
|
|
||||||
@ -102,43 +86,29 @@ EndFunction
|
|||||||
|
|
||||||
#Region MultipartRequests
|
#Region MultipartRequests
|
||||||
|
|
||||||
Function PostMultipart(Val URL
|
Function PostMultipart(Val URL, Val Parameters = "", Val Files = "", Val ContentType = "image/jpeg",
|
||||||
, Val Parameters = ""
|
Val AdditionalHeaders = "", Val ResponseFile = Undefined) Export
|
||||||
, Val Files = ""
|
|
||||||
, Val ContentType = "image/jpeg"
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val ResponseFile = Undefined) Export
|
|
||||||
|
|
||||||
Return ExecuteMultipartRequest(URL, "POST", Parameters, Files, ContentType, AdditionalHeaders, ResponseFile);
|
Return ExecuteMultipartRequest(URL, "POST", Parameters, Files, ContentType, AdditionalHeaders, ResponseFile);
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function PutMultipart(Val URL
|
Function PutMultipart(Val URL, Val Parameters = "", Val Files = "", Val ContentType = "image/jpeg",
|
||||||
, Val Parameters = ""
|
Val AdditionalHeaders = "", Val ResponseFile = Undefined) Export
|
||||||
, Val Files = ""
|
|
||||||
, Val ContentType = "image/jpeg"
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val ResponseFile = Undefined) Export
|
|
||||||
|
|
||||||
Return ExecuteMultipartRequest(URL, "PUT", Parameters, Files, ContentType, AdditionalHeaders, ResponseFile);
|
Return ExecuteMultipartRequest(URL, "PUT", Parameters, Files, ContentType, AdditionalHeaders, ResponseFile);
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function PostMultipartRelated(Val URL
|
Function PostMultipartRelated(Val URL, Val JSON = "", Val Files = "", Val AdditionalHeaders = "",
|
||||||
, Val JSON = ""
|
Val ResponseFile = Undefined) Export
|
||||||
, Val Files = ""
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val ResponseFile = Undefined) Export
|
|
||||||
|
|
||||||
Return ExecuteMultipartRelatedRequest(URL, "POST", JSON, Files, AdditionalHeaders, ResponseFile);
|
Return ExecuteMultipartRelatedRequest(URL, "POST", JSON, Files, AdditionalHeaders, ResponseFile);
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function PatchMultipartRelated(Val URL
|
Function PatchMultipartRelated(Val URL, Val JSON = "", Val Files = "", Val AdditionalHeaders = "",
|
||||||
, Val JSON = ""
|
Val ResponseFile = Undefined) Export
|
||||||
, Val Files = ""
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val ResponseFile = Undefined) Export
|
|
||||||
|
|
||||||
Return ExecuteMultipartRelatedRequest(URL, "PATCH", JSON, Files, AdditionalHeaders, ResponseFile);
|
Return ExecuteMultipartRelatedRequest(URL, "PATCH", JSON, Files, AdditionalHeaders, ResponseFile);
|
||||||
|
|
||||||
@ -162,9 +132,8 @@ Procedure ProcessResponse(Response, Val FullResponse = False) Export
|
|||||||
EndIf;
|
EndIf;
|
||||||
|
|
||||||
GZip = "gzip";
|
GZip = "gzip";
|
||||||
NeedsUnpacking =
|
NeedsUnpacking = Response.Headers.Get("Content-Encoding") = GZip Or Response.Headers.Get(
|
||||||
Response.Headers.Get("Content-Encoding") = GZip
|
"content-encoding") = GZip;
|
||||||
Or Response.Headers.Get("content-encoding") = GZip;
|
|
||||||
|
|
||||||
If NeedsUnpacking Then
|
If NeedsUnpacking Then
|
||||||
Response = UnpackResponse(Response);
|
Response = UnpackResponse(Response);
|
||||||
@ -276,12 +245,8 @@ Function CreateRequestWithBody(Val Address, Val Parameters, Val AdditionalHeader
|
|||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function CreateMultipartRequest(Val Address
|
Function CreateMultipartRequest(Val Address, Val Parameters, Val Files, Val AdditionalHeaders, Val FileName,
|
||||||
, Val Parameters
|
Val ContentType) Export
|
||||||
, Val Files
|
|
||||||
, Val AdditionalHeaders
|
|
||||||
, Val FileName
|
|
||||||
, Val ContentType) Export
|
|
||||||
|
|
||||||
Boundary = StrReplace(String(New UUID), "-", "");
|
Boundary = StrReplace(String(New UUID), "-", "");
|
||||||
LineSeparator = Chars.CR + Chars.LF;
|
LineSeparator = Chars.CR + Chars.LF;
|
||||||
@ -289,13 +254,7 @@ Function CreateMultipartRequest(Val Address
|
|||||||
|
|
||||||
Request = CreateRequest(Address, AdditionalHeaders, DataType);
|
Request = CreateRequest(Address, AdditionalHeaders, DataType);
|
||||||
|
|
||||||
TextRecord = New DataWriter(FileName
|
TextRecord = New DataWriter(FileName, TextEncoding.UTF8, ByteOrder.LittleEndian, "", False, "", False);
|
||||||
, TextEncoding.UTF8
|
|
||||||
, ByteOrder.LittleEndian
|
|
||||||
, ""
|
|
||||||
, False
|
|
||||||
, ""
|
|
||||||
, False);
|
|
||||||
|
|
||||||
WriteMultipartParameters(TextRecord, Boundary, Parameters);
|
WriteMultipartParameters(TextRecord, Boundary, Parameters);
|
||||||
WriteMultipartFiles(TextRecord, Boundary, ContentType, Files);
|
WriteMultipartFiles(TextRecord, Boundary, ContentType, Files);
|
||||||
@ -316,13 +275,7 @@ Function CreateMultipartRelatedRequest(Val Address, Val Files, Val JSON, Val Add
|
|||||||
DataType = "multipart/related; boundary=" + Boundary;
|
DataType = "multipart/related; boundary=" + Boundary;
|
||||||
|
|
||||||
Request = CreateRequest(Address, AdditionalHeaders, DataType);
|
Request = CreateRequest(Address, AdditionalHeaders, DataType);
|
||||||
TextRecord = New DataWriter(FileName
|
TextRecord = New DataWriter(FileName, TextEncoding.UTF8, ByteOrder.LittleEndian, "", False, "", False);
|
||||||
, TextEncoding.UTF8
|
|
||||||
, ByteOrder.LittleEndian
|
|
||||||
, ""
|
|
||||||
, False
|
|
||||||
, ""
|
|
||||||
, False);
|
|
||||||
|
|
||||||
WriteJSONMultipart(TextRecord, Boundary, JSON);
|
WriteJSONMultipart(TextRecord, Boundary, JSON);
|
||||||
WriteRelatedFiles(TextRecord, Boundary, Files);
|
WriteRelatedFiles(TextRecord, Boundary, Files);
|
||||||
@ -361,11 +314,7 @@ Function RequestParametersToString(Val Parameters, Val SplitArrayParams = False,
|
|||||||
|
|
||||||
ParameterValue = ConvertParameterToString(CurrentValue);
|
ParameterValue = ConvertParameterToString(CurrentValue);
|
||||||
|
|
||||||
ParameterString = ParameterString
|
ParameterString = ParameterString + Parameter.Key + "=" + ParameterValue + "&";
|
||||||
+ Parameter.Key
|
|
||||||
+ "="
|
|
||||||
+ ParameterValue
|
|
||||||
+ "&";
|
|
||||||
|
|
||||||
Else
|
Else
|
||||||
|
|
||||||
@ -404,7 +353,7 @@ Function SplitURL(Val URL) Export
|
|||||||
|
|
||||||
ReturnStructure = New Structure;
|
ReturnStructure = New Structure;
|
||||||
ReturnStructure.Insert("Host" , Host);
|
ReturnStructure.Insert("Host" , Host);
|
||||||
ReturnStructure.Insert("Address" , Address);
|
ReturnStructure.Insert("Address", Address);
|
||||||
ReturnStructure.Insert("Safe" , SecureConnection);
|
ReturnStructure.Insert("Safe" , SecureConnection);
|
||||||
|
|
||||||
Return ReturnStructure;
|
Return ReturnStructure;
|
||||||
@ -429,21 +378,12 @@ Function JsonToStructure(Val Text) Export
|
|||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function JSONString(Val Data
|
Function JSONString(Val Data, Val Escaping = "None", Val LineBreaks = True, Val DoubleQuotes = True) Export
|
||||||
, Val Escaping = "None"
|
|
||||||
, Val LineBreaks = True
|
|
||||||
, Val DoubleQuotes = True) Export
|
|
||||||
|
|
||||||
LineBreak = ?(LineBreaks, JSONLineBreak.Windows, JSONLineBreak.None);
|
LineBreak = ?(LineBreaks, JSONLineBreak.Windows, JSONLineBreak.None);
|
||||||
|
|
||||||
JSONParameters = New JSONWriterSettings(LineBreak
|
JSONParameters = New JSONWriterSettings(LineBreak, " ", DoubleQuotes, JSONCharactersEscapeMode[Escaping],
|
||||||
, " "
|
False, False, False, False);
|
||||||
, DoubleQuotes
|
|
||||||
, JSONCharactersEscapeMode[Escaping]
|
|
||||||
, False
|
|
||||||
, False
|
|
||||||
, False
|
|
||||||
, False);
|
|
||||||
|
|
||||||
Try
|
Try
|
||||||
|
|
||||||
@ -571,17 +511,40 @@ Function CollectionFieldExists(Val Collection, Val Field) Export
|
|||||||
|
|
||||||
CollectionType = TypeOf(Collection);
|
CollectionType = TypeOf(Collection);
|
||||||
|
|
||||||
If CollectionType = Type("Structure") Then
|
IsStructure = CollectionType = Type("Structure");
|
||||||
|
IsMap = CollectionType = Type("Map");
|
||||||
|
ThisIsCollection = IsStructure Or IsMap;
|
||||||
|
|
||||||
|
If StrFind(Field, ".") And ThisIsCollection Then
|
||||||
|
|
||||||
|
FieldParts = StrSplit(Field, ".");
|
||||||
|
CurrentField = FieldParts[0];
|
||||||
|
|
||||||
|
If Not CollectionFieldExists(Collection, CurrentField) Then
|
||||||
|
|
||||||
|
Return False;
|
||||||
|
|
||||||
|
Else
|
||||||
|
|
||||||
|
FieldParts.Delete(0);
|
||||||
|
NextCollection = Collection[CurrentField];
|
||||||
|
NextField = StrConcat(FieldParts, ".");
|
||||||
|
|
||||||
|
Return CollectionFieldExists(NextCollection, NextField);
|
||||||
|
|
||||||
|
EndIf;
|
||||||
|
|
||||||
|
ElsIf IsStructure Then
|
||||||
|
|
||||||
Return Collection.Property(Field);
|
Return Collection.Property(Field);
|
||||||
|
|
||||||
ElsIf CollectionType = Type("Map") Then
|
ElsIf IsMap Then
|
||||||
|
|
||||||
Return Collection[Field] <> Undefined;
|
Return Collection[Field] <> Undefined;
|
||||||
|
|
||||||
Else
|
Else
|
||||||
|
|
||||||
Raise "The specified value is not a valid collection!";
|
Return False;
|
||||||
|
|
||||||
EndIf;
|
EndIf;
|
||||||
|
|
||||||
@ -676,7 +639,7 @@ Function IsOneScript() Export
|
|||||||
// BSLLS:UnusedLocalVariable-off
|
// BSLLS:UnusedLocalVariable-off
|
||||||
|
|
||||||
//@skip-check module-unused-local-variable
|
//@skip-check module-unused-local-variable
|
||||||
Check = New OpenSSLSecureConnection();
|
Check = New OpenSSLSecureConnection;
|
||||||
|
|
||||||
// BSLLS:UnusedLocalVariable-on
|
// BSLLS:UnusedLocalVariable-on
|
||||||
|
|
||||||
@ -778,9 +741,7 @@ EndFunction
|
|||||||
|
|
||||||
Function RelevantNodeType(Val NodeType)
|
Function RelevantNodeType(Val NodeType)
|
||||||
|
|
||||||
Return NodeType = XMLNodeType.StartElement
|
Return NodeType = XMLNodeType.StartElement Or NodeType = XMLNodeType.EndElement Or NodeType = XMLNodeType.Text;
|
||||||
Or NodeType = XMLNodeType.EndElement
|
|
||||||
Or NodeType = XMLNodeType.Text;
|
|
||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
@ -827,7 +788,7 @@ EndProcedure
|
|||||||
Procedure RemoveEmptyCollectionFields(Collection) Export
|
Procedure RemoveEmptyCollectionFields(Collection) Export
|
||||||
|
|
||||||
CollectionType = TypeOf(Collection);
|
CollectionType = TypeOf(Collection);
|
||||||
OutputCollection = New(CollectionType);
|
OutputCollection = New (CollectionType);
|
||||||
|
|
||||||
If CollectionType = Type("Map") Or CollectionType = Type("Structure") Then
|
If CollectionType = Type("Map") Or CollectionType = Type("Structure") Then
|
||||||
|
|
||||||
@ -923,13 +884,8 @@ EndProcedure
|
|||||||
|
|
||||||
#Region Private
|
#Region Private
|
||||||
|
|
||||||
Function ExecuteRequestWithBody(Val URL
|
Function ExecuteRequestWithBody(Val URL, Val View, Val Parameters = "", Val AdditionalHeaders = "", Val JSON = True,
|
||||||
, Val View
|
Val FullResponse = False, Val ResponseFile = Undefined)
|
||||||
, Val Parameters = ""
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val JSON = True
|
|
||||||
, Val FullResponse = False
|
|
||||||
, Val ResponseFile = Undefined)
|
|
||||||
|
|
||||||
If Not ValueIsFilled(Parameters) Then
|
If Not ValueIsFilled(Parameters) Then
|
||||||
Parameters = New Structure;
|
Parameters = New Structure;
|
||||||
@ -948,12 +904,8 @@ Function ExecuteRequestWithBody(Val URL
|
|||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function ExecuteRequestWithBinaryData(Val URL
|
Function ExecuteRequestWithBinaryData(Val URL, Val View, Val Data, Val AdditionalHeaders, Val FullResponse,
|
||||||
, Val View
|
Val DataType)
|
||||||
, Val Data
|
|
||||||
, Val AdditionalHeaders
|
|
||||||
, Val FullResponse
|
|
||||||
, Val DataType)
|
|
||||||
|
|
||||||
URLStructure = SplitURL(URL);
|
URLStructure = SplitURL(URL);
|
||||||
Host = URLStructure["Host"];
|
Host = URLStructure["Host"];
|
||||||
@ -973,11 +925,8 @@ Function ExecuteRequestWithBinaryData(Val URL
|
|||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function ExecuteRequestWithoutBody(Val URL
|
Function ExecuteRequestWithoutBody(Val URL, Val View, Val Parameters = "", Val AdditionalHeaders = "",
|
||||||
, Val View
|
Val ResponseFile = Undefined)
|
||||||
, Val Parameters = ""
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val ResponseFile = Undefined)
|
|
||||||
|
|
||||||
If Not ValueIsFilled(Parameters) Then
|
If Not ValueIsFilled(Parameters) Then
|
||||||
Parameters = New Structure;
|
Parameters = New Structure;
|
||||||
@ -997,13 +946,8 @@ Function ExecuteRequestWithoutBody(Val URL
|
|||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function ExecuteMultipartRequest(Val URL
|
Function ExecuteMultipartRequest(Val URL, Val View, Val Parameters = "", Val Files = "",
|
||||||
, Val View
|
Val ContentType = "image/jpeg", Val AdditionalHeaders = "", Val ResponseFile = Undefined)
|
||||||
, Val Parameters = ""
|
|
||||||
, Val Files = ""
|
|
||||||
, Val ContentType = "image/jpeg"
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val ResponseFile = Undefined)
|
|
||||||
|
|
||||||
If Not ValueIsFilled(Parameters) Then
|
If Not ValueIsFilled(Parameters) Then
|
||||||
Parameters = New Structure;
|
Parameters = New Structure;
|
||||||
@ -1032,12 +976,8 @@ Function ExecuteMultipartRequest(Val URL
|
|||||||
|
|
||||||
EndFunction
|
EndFunction
|
||||||
|
|
||||||
Function ExecuteMultipartRelatedRequest(Val URL
|
Function ExecuteMultipartRelatedRequest(Val URL, Val View, Val JSON = "", Val Files = "", Val AdditionalHeaders = "",
|
||||||
, Val View
|
Val ResponseFile = Undefined)
|
||||||
, Val JSON = ""
|
|
||||||
, Val Files = ""
|
|
||||||
, Val AdditionalHeaders = ""
|
|
||||||
, Val ResponseFile = Undefined)
|
|
||||||
|
|
||||||
URLStructure = SplitURL(URL);
|
URLStructure = SplitURL(URL);
|
||||||
Host = URLStructure["Host"];
|
Host = URLStructure["Host"];
|
||||||
@ -1064,9 +1004,8 @@ Function ThisIsRedirection(Val Response)
|
|||||||
Redirection = 300;
|
Redirection = 300;
|
||||||
Error = 400;
|
Error = 400;
|
||||||
|
|
||||||
ThisIsRedirection = Response.StatusCode >= Redirection
|
ThisIsRedirection = Response.StatusCode >= Redirection And Response.StatusCode < Error And ValueIsFilled(
|
||||||
And Response.StatusCode < Error
|
Response.Headers["Location"]);
|
||||||
And ValueIsFilled(Response.Headers["Location"]);
|
|
||||||
|
|
||||||
Return ThisIsRedirection;
|
Return ThisIsRedirection;
|
||||||
|
|
||||||
@ -1162,9 +1101,8 @@ EndFunction
|
|||||||
|
|
||||||
Procedure SetRequestBody(Request, Val Parameters, Val JSON)
|
Procedure SetRequestBody(Request, Val Parameters, Val JSON)
|
||||||
|
|
||||||
Collection = TypeOf(Parameters) = Type("Structure")
|
Collection = TypeOf(Parameters) = Type("Structure") Or TypeOf(Parameters) = Type("Map") Or TypeOf(Parameters)
|
||||||
Or TypeOf(Parameters) = Type("Map")
|
= Type("Array");
|
||||||
Or TypeOf(Parameters) = Type("Array");
|
|
||||||
|
|
||||||
If JSON Then
|
If JSON Then
|
||||||
|
|
||||||
@ -1196,8 +1134,7 @@ Procedure WriteMultipartParameters(TextRecord, Val Boundary, Val Parameters)
|
|||||||
|
|
||||||
For Each Parameter In Parameters Do
|
For Each Parameter In Parameters Do
|
||||||
|
|
||||||
If Parameter.Value = Undefined
|
If Parameter.Value = Undefined Or Parameter.Value = Null Then
|
||||||
Or Parameter.Value = NULL Then
|
|
||||||
Continue;
|
Continue;
|
||||||
EndIf;
|
EndIf;
|
||||||
|
|
||||||
@ -1206,8 +1143,7 @@ Procedure WriteMultipartParameters(TextRecord, Val Boundary, Val Parameters)
|
|||||||
TextRecord.WriteLine(LineSeparator);
|
TextRecord.WriteLine(LineSeparator);
|
||||||
TextRecord.WriteLine(LineSeparator);
|
TextRecord.WriteLine(LineSeparator);
|
||||||
|
|
||||||
If TypeOf(Parameter.Value) = Type("String")
|
If TypeOf(Parameter.Value) = Type("String") Or TypeOf(Parameter.Value) = Type("Number") Then
|
||||||
Or TypeOf(Parameter.Value) = Type("Number") Then
|
|
||||||
|
|
||||||
ValueAsString = NumberToString(Parameter.Value);
|
ValueAsString = NumberToString(Parameter.Value);
|
||||||
TextRecord.WriteLine(ValueAsString);
|
TextRecord.WriteLine(ValueAsString);
|
||||||
@ -1241,10 +1177,7 @@ Procedure WriteMultipartFiles(TextRecord, Val Boundary, Val ContentType, Val Fil
|
|||||||
FileName = DataStructure["FileName"];
|
FileName = DataStructure["FileName"];
|
||||||
|
|
||||||
TextRecord.WriteLine("--" + boundary + LineSeparator);
|
TextRecord.WriteLine("--" + boundary + LineSeparator);
|
||||||
TextRecord.WriteLine("Content-Disposition: form-data; name="""
|
TextRecord.WriteLine("Content-Disposition: form-data; name=""" + FieldName + """; filename=""" + FileName
|
||||||
+ FieldName
|
|
||||||
+ """; filename="""
|
|
||||||
+ FileName
|
|
||||||
+ """");
|
+ """");
|
||||||
TextRecord.WriteLine(LineSeparator);
|
TextRecord.WriteLine(LineSeparator);
|
||||||
|
|
||||||
@ -1351,7 +1284,7 @@ Procedure RemoveEmptyKeyValues(Val Collection, OutputCollection)
|
|||||||
|
|
||||||
For Each CollectionItem In Collection Do
|
For Each CollectionItem In Collection Do
|
||||||
|
|
||||||
If Not CollectionItem.Value = Undefined And Not CollectionItem.Value = NULL Then
|
If Not CollectionItem.Value = Undefined And Not CollectionItem.Value = Null Then
|
||||||
OutputCollection.Insert(CollectionItem.Key, CollectionItem.Value);
|
OutputCollection.Insert(CollectionItem.Key, CollectionItem.Value);
|
||||||
EndIf;
|
EndIf;
|
||||||
|
|
||||||
@ -1363,7 +1296,7 @@ Procedure RemoveEmptyArrayItems(Val Collection, OutputCollection)
|
|||||||
|
|
||||||
For Each CollectionItem In Collection Do
|
For Each CollectionItem In Collection Do
|
||||||
|
|
||||||
If Not CollectionItem = Undefined And Not CollectionItem = NULL Then
|
If Not CollectionItem = Undefined And Not CollectionItem = Null Then
|
||||||
OutputCollection.Add(CollectionItem);
|
OutputCollection.Add(CollectionItem);
|
||||||
EndIf;
|
EndIf;
|
||||||
|
|
||||||
@ -1454,11 +1387,7 @@ Function ReadGZip(CompressedData) Export
|
|||||||
DataReader.Skip(GZipPrefixSize);
|
DataReader.Skip(GZipPrefixSize);
|
||||||
CompressedDataSize = DataReader.SourceStream().Size() - GZipPrefixSize - GZipPostfixSize;
|
CompressedDataSize = DataReader.SourceStream().Size() - GZipPrefixSize - GZipPostfixSize;
|
||||||
|
|
||||||
ZipStream = New MemoryStream(SizeLFH
|
ZipStream = New MemoryStream(SizeLFH + CompressedDataSize + SizeDD + SizeCDH + SizeESD);
|
||||||
+ CompressedDataSize
|
|
||||||
+ SizeDD
|
|
||||||
+ SizeCDH
|
|
||||||
+ SizeESD);
|
|
||||||
|
|
||||||
DataWriter = New DataWriter(ZipStream);
|
DataWriter = New DataWriter(ZipStream);
|
||||||
DataWriter.WriteBinaryDataBuffer(ZipLFH());
|
DataWriter.WriteBinaryDataBuffer(ZipLFH());
|
||||||
|
@ -82,6 +82,16 @@
|
|||||||
NewLine.Область = "Common methods";
|
NewLine.Область = "Common methods";
|
||||||
|
|
||||||
|
|
||||||
|
NewLine = CompositionTable.Add();
|
||||||
|
NewLine.Библиотека = "s3";
|
||||||
|
NewLine.Модуль = "OPI_S3";
|
||||||
|
NewLine.Метод = "SendRequestWithoutBody";
|
||||||
|
NewLine.МетодПоиска = "SENDREQUESTWITHOUTBODY";
|
||||||
|
NewLine.Параметр = "--binary";
|
||||||
|
NewLine.Описание = "Disables an attempt to convert the response to JSON (optional, def. val. - No)";
|
||||||
|
NewLine.Область = "Common methods";
|
||||||
|
|
||||||
|
|
||||||
NewLine = CompositionTable.Add();
|
NewLine = CompositionTable.Add();
|
||||||
NewLine.Библиотека = "s3";
|
NewLine.Библиотека = "s3";
|
||||||
NewLine.Модуль = "OPI_S3";
|
NewLine.Модуль = "OPI_S3";
|
||||||
@ -123,6 +133,16 @@
|
|||||||
NewLine.Область = "Common methods";
|
NewLine.Область = "Common methods";
|
||||||
|
|
||||||
|
|
||||||
|
NewLine = CompositionTable.Add();
|
||||||
|
NewLine.Библиотека = "s3";
|
||||||
|
NewLine.Модуль = "OPI_S3";
|
||||||
|
NewLine.Метод = "SendRequestWithBody";
|
||||||
|
NewLine.МетодПоиска = "SENDREQUESTWITHBODY";
|
||||||
|
NewLine.Параметр = "--binary";
|
||||||
|
NewLine.Описание = "Disables an attempt to convert the response to JSON (optional, def. val. - No)";
|
||||||
|
NewLine.Область = "Common methods";
|
||||||
|
|
||||||
|
|
||||||
NewLine = CompositionTable.Add();
|
NewLine = CompositionTable.Add();
|
||||||
NewLine.Библиотека = "s3";
|
NewLine.Библиотека = "s3";
|
||||||
NewLine.Модуль = "OPI_S3";
|
NewLine.Модуль = "OPI_S3";
|
||||||
@ -787,6 +807,77 @@
|
|||||||
NewLine.Область = "Objects managment";
|
NewLine.Область = "Objects managment";
|
||||||
|
|
||||||
|
|
||||||
|
NewLine = CompositionTable.Add();
|
||||||
|
NewLine.Библиотека = "s3";
|
||||||
|
NewLine.Модуль = "OPI_S3";
|
||||||
|
NewLine.Метод = "GetObject";
|
||||||
|
NewLine.МетодПоиска = "GETOBJECT";
|
||||||
|
NewLine.Параметр = "--name";
|
||||||
|
NewLine.Описание = "Name of the object in the bucket";
|
||||||
|
NewLine.Область = "Objects managment";
|
||||||
|
NewLine.ОписаниеМетода = "Gets the contents of the object from the bucket";
|
||||||
|
|
||||||
|
|
||||||
|
NewLine = CompositionTable.Add();
|
||||||
|
NewLine.Библиотека = "s3";
|
||||||
|
NewLine.Модуль = "OPI_S3";
|
||||||
|
NewLine.Метод = "GetObject";
|
||||||
|
NewLine.МетодПоиска = "GETOBJECT";
|
||||||
|
NewLine.Параметр = "--bucket";
|
||||||
|
NewLine.Описание = "Name of the bucket in which the object is stored";
|
||||||
|
NewLine.Область = "Objects managment";
|
||||||
|
|
||||||
|
|
||||||
|
NewLine = CompositionTable.Add();
|
||||||
|
NewLine.Библиотека = "s3";
|
||||||
|
NewLine.Модуль = "OPI_S3";
|
||||||
|
NewLine.Метод = "GetObject";
|
||||||
|
NewLine.МетодПоиска = "GETOBJECT";
|
||||||
|
NewLine.Параметр = "--basic";
|
||||||
|
NewLine.Описание = "Basic request data. See GetBasicDataStructure";
|
||||||
|
NewLine.Область = "Objects managment";
|
||||||
|
|
||||||
|
|
||||||
|
NewLine = CompositionTable.Add();
|
||||||
|
NewLine.Библиотека = "s3";
|
||||||
|
NewLine.Модуль = "OPI_S3";
|
||||||
|
NewLine.Метод = "GetObject";
|
||||||
|
NewLine.МетодПоиска = "GETOBJECT";
|
||||||
|
NewLine.Параметр = "--dir";
|
||||||
|
NewLine.Описание = "True > Directory Bucket, False > General Purpose Bucket";
|
||||||
|
NewLine.Область = "Objects managment";
|
||||||
|
|
||||||
|
|
||||||
|
NewLine = CompositionTable.Add();
|
||||||
|
NewLine.Библиотека = "s3";
|
||||||
|
NewLine.Модуль = "OPI_S3";
|
||||||
|
NewLine.Метод = "GetObject";
|
||||||
|
NewLine.МетодПоиска = "GETOBJECT";
|
||||||
|
NewLine.Параметр = "--ver";
|
||||||
|
NewLine.Описание = "Token for receiving a specific version of an object (optional, def. val. - Empty value)";
|
||||||
|
NewLine.Область = "Objects managment";
|
||||||
|
|
||||||
|
|
||||||
|
NewLine = CompositionTable.Add();
|
||||||
|
NewLine.Библиотека = "s3";
|
||||||
|
NewLine.Модуль = "OPI_S3";
|
||||||
|
NewLine.Метод = "GetObject";
|
||||||
|
NewLine.МетодПоиска = "GETOBJECT";
|
||||||
|
NewLine.Параметр = "--headers";
|
||||||
|
NewLine.Описание = "Additional request headers, if necessary (optional, def. val. - Empty value)";
|
||||||
|
NewLine.Область = "Objects managment";
|
||||||
|
|
||||||
|
|
||||||
|
NewLine = CompositionTable.Add();
|
||||||
|
NewLine.Библиотека = "s3";
|
||||||
|
NewLine.Модуль = "OPI_S3";
|
||||||
|
NewLine.Метод = "GetObject";
|
||||||
|
NewLine.МетодПоиска = "GETOBJECT";
|
||||||
|
NewLine.Параметр = "--out";
|
||||||
|
NewLine.Описание = "Path to directly write a file to disk (optional, def. val. - Empty value)";
|
||||||
|
NewLine.Область = "Objects managment";
|
||||||
|
|
||||||
|
|
||||||
NewLine = CompositionTable.Add();
|
NewLine = CompositionTable.Add();
|
||||||
NewLine.Библиотека = "s3";
|
NewLine.Библиотека = "s3";
|
||||||
NewLine.Модуль = "OPI_S3";
|
NewLine.Модуль = "OPI_S3";
|
||||||
|
@ -161,9 +161,9 @@
|
|||||||
|
|
||||||
Заголовки = Новый Соответствие;
|
Заголовки = Новый Соответствие;
|
||||||
Заголовки.Вставить("Accept-Encoding", "gzip");
|
Заголовки.Вставить("Accept-Encoding", "gzip");
|
||||||
Заголовки.Вставить("Accept", "*/*");
|
Заголовки.Вставить("Accept" , "*/*");
|
||||||
Заголовки.Вставить("Connection", "keep-alive");
|
Заголовки.Вставить("Connection" , "keep-alive");
|
||||||
Заголовки.Вставить("Accept-Charset", "utf-8");
|
Заголовки.Вставить("Accept-Charset" , "utf-8");
|
||||||
|
|
||||||
Если ЗначениеЗаполнено(ТипДанных) Тогда
|
Если ЗначениеЗаполнено(ТипДанных) Тогда
|
||||||
Заголовки.Вставить("Content-Type", ТипДанных);
|
Заголовки.Вставить("Content-Type", ТипДанных);
|
||||||
@ -336,8 +336,8 @@
|
|||||||
ЗащищенноеСоединение = Не СтрНачинаетсяС(URL, "http://");
|
ЗащищенноеСоединение = Не СтрНачинаетсяС(URL, "http://");
|
||||||
|
|
||||||
URL = СтрЗаменить(URL, "https://", "");
|
URL = СтрЗаменить(URL, "https://", "");
|
||||||
URL = СтрЗаменить(URL, "http://", "");
|
URL = СтрЗаменить(URL, "http://" , "");
|
||||||
URL = СтрЗаменить(URL, ":443", "");
|
URL = СтрЗаменить(URL, ":443" , "");
|
||||||
|
|
||||||
Если СтрНайти(URL, "/") = 0 Тогда
|
Если СтрНайти(URL, "/") = 0 Тогда
|
||||||
Адрес = "";
|
Адрес = "";
|
||||||
@ -352,8 +352,8 @@
|
|||||||
КонецЕсли;
|
КонецЕсли;
|
||||||
|
|
||||||
СтруктураВозврата = Новый Структура;
|
СтруктураВозврата = Новый Структура;
|
||||||
СтруктураВозврата.Вставить("Сервер", Сервер);
|
СтруктураВозврата.Вставить("Сервер" , Сервер);
|
||||||
СтруктураВозврата.Вставить("Адрес", Адрес);
|
СтруктураВозврата.Вставить("Адрес" , Адрес);
|
||||||
СтруктураВозврата.Вставить("Защищенное", ЗащищенноеСоединение);
|
СтруктураВозврата.Вставить("Защищенное", ЗащищенноеСоединение);
|
||||||
|
|
||||||
Возврат СтруктураВозврата;
|
Возврат СтруктураВозврата;
|
||||||
@ -447,9 +447,9 @@
|
|||||||
Дата = ОТД.ПривестиЗначение(Дата);
|
Дата = ОТД.ПривестиЗначение(Дата);
|
||||||
|
|
||||||
UNIX = Формат(Дата - Дата(1970, 1, 1, 1, 0, 0), "ЧЦ=10; ЧДЦ=0; ЧГ=0");
|
UNIX = Формат(Дата - Дата(1970, 1, 1, 1, 0, 0), "ЧЦ=10; ЧДЦ=0; ЧГ=0");
|
||||||
UNIX = СтрЗаменить(UNIX, ",", "");
|
UNIX = СтрЗаменить(UNIX, "," , "");
|
||||||
UNIX = СтрЗаменить(UNIX, Символы.НПП, "");
|
UNIX = СтрЗаменить(UNIX, Символы.НПП, "");
|
||||||
UNIX = СтрЗаменить(UNIX, " ", "");
|
UNIX = СтрЗаменить(UNIX, " " , "");
|
||||||
UNIX = Лев(UNIX, 10);
|
UNIX = Лев(UNIX, 10);
|
||||||
|
|
||||||
Возврат UNIX;
|
Возврат UNIX;
|
||||||
@ -1400,7 +1400,7 @@
|
|||||||
РазмерНесжатыхДанных = ЧтениеДанных.ПрочитатьЦелое32();
|
РазмерНесжатыхДанных = ЧтениеДанных.ПрочитатьЦелое32();
|
||||||
ЧтениеДанных.Закрыть();
|
ЧтениеДанных.Закрыть();
|
||||||
|
|
||||||
ЗаписьДанных.ЗаписатьБуферДвоичныхДанных(ZipDD(CRC32, РазмерСжатыхДанных, РазмерНесжатыхДанных));
|
ЗаписьДанных.ЗаписатьБуферДвоичныхДанных(ZipDD(CRC32 , РазмерСжатыхДанных, РазмерНесжатыхДанных));
|
||||||
ЗаписьДанных.ЗаписатьБуферДвоичныхДанных(ZipCDH(CRC32, РазмерСжатыхДанных, РазмерНесжатыхДанных));
|
ЗаписьДанных.ЗаписатьБуферДвоичныхДанных(ZipCDH(CRC32, РазмерСжатыхДанных, РазмерНесжатыхДанных));
|
||||||
ЗаписьДанных.ЗаписатьБуферДвоичныхДанных(ZipEOCD(РазмерСжатыхДанных));
|
ЗаписьДанных.ЗаписатьБуферДвоичныхДанных(ZipEOCD(РазмерСжатыхДанных));
|
||||||
ЗаписьДанных.Закрыть();
|
ЗаписьДанных.Закрыть();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// OneScript: ./OInt/core/Modules/OPI_S3.os
|
// OneScript: ./OInt/core/Modules/OPI_S3.os
|
||||||
// Lib: S3
|
// Lib: S3
|
||||||
// CLI: s3
|
// CLI: s3
|
||||||
|
|
||||||
|
@ -161,9 +161,9 @@
|
|||||||
|
|
||||||
Заголовки = Новый Соответствие;
|
Заголовки = Новый Соответствие;
|
||||||
Заголовки.Вставить("Accept-Encoding", "gzip");
|
Заголовки.Вставить("Accept-Encoding", "gzip");
|
||||||
Заголовки.Вставить("Accept", "*/*");
|
Заголовки.Вставить("Accept" , "*/*");
|
||||||
Заголовки.Вставить("Connection", "keep-alive");
|
Заголовки.Вставить("Connection" , "keep-alive");
|
||||||
Заголовки.Вставить("Accept-Charset", "utf-8");
|
Заголовки.Вставить("Accept-Charset" , "utf-8");
|
||||||
|
|
||||||
Если ЗначениеЗаполнено(ТипДанных) Тогда
|
Если ЗначениеЗаполнено(ТипДанных) Тогда
|
||||||
Заголовки.Вставить("Content-Type", ТипДанных);
|
Заголовки.Вставить("Content-Type", ТипДанных);
|
||||||
@ -336,8 +336,8 @@
|
|||||||
ЗащищенноеСоединение = Не СтрНачинаетсяС(URL, "http://");
|
ЗащищенноеСоединение = Не СтрНачинаетсяС(URL, "http://");
|
||||||
|
|
||||||
URL = СтрЗаменить(URL, "https://", "");
|
URL = СтрЗаменить(URL, "https://", "");
|
||||||
URL = СтрЗаменить(URL, "http://", "");
|
URL = СтрЗаменить(URL, "http://" , "");
|
||||||
URL = СтрЗаменить(URL, ":443", "");
|
URL = СтрЗаменить(URL, ":443" , "");
|
||||||
|
|
||||||
Если СтрНайти(URL, "/") = 0 Тогда
|
Если СтрНайти(URL, "/") = 0 Тогда
|
||||||
Адрес = "";
|
Адрес = "";
|
||||||
@ -352,8 +352,8 @@
|
|||||||
КонецЕсли;
|
КонецЕсли;
|
||||||
|
|
||||||
СтруктураВозврата = Новый Структура;
|
СтруктураВозврата = Новый Структура;
|
||||||
СтруктураВозврата.Вставить("Сервер", Сервер);
|
СтруктураВозврата.Вставить("Сервер" , Сервер);
|
||||||
СтруктураВозврата.Вставить("Адрес", Адрес);
|
СтруктураВозврата.Вставить("Адрес" , Адрес);
|
||||||
СтруктураВозврата.Вставить("Защищенное", ЗащищенноеСоединение);
|
СтруктураВозврата.Вставить("Защищенное", ЗащищенноеСоединение);
|
||||||
|
|
||||||
Возврат СтруктураВозврата;
|
Возврат СтруктураВозврата;
|
||||||
@ -447,9 +447,9 @@
|
|||||||
Дата = ОТД.ПривестиЗначение(Дата);
|
Дата = ОТД.ПривестиЗначение(Дата);
|
||||||
|
|
||||||
UNIX = Формат(Дата - Дата(1970, 1, 1, 1, 0, 0), "ЧЦ=10; ЧДЦ=0; ЧГ=0");
|
UNIX = Формат(Дата - Дата(1970, 1, 1, 1, 0, 0), "ЧЦ=10; ЧДЦ=0; ЧГ=0");
|
||||||
UNIX = СтрЗаменить(UNIX, ",", "");
|
UNIX = СтрЗаменить(UNIX, "," , "");
|
||||||
UNIX = СтрЗаменить(UNIX, Символы.НПП, "");
|
UNIX = СтрЗаменить(UNIX, Символы.НПП, "");
|
||||||
UNIX = СтрЗаменить(UNIX, " ", "");
|
UNIX = СтрЗаменить(UNIX, " " , "");
|
||||||
UNIX = Лев(UNIX, 10);
|
UNIX = Лев(UNIX, 10);
|
||||||
|
|
||||||
Возврат UNIX;
|
Возврат UNIX;
|
||||||
@ -1400,7 +1400,7 @@
|
|||||||
РазмерНесжатыхДанных = ЧтениеДанных.ПрочитатьЦелое32();
|
РазмерНесжатыхДанных = ЧтениеДанных.ПрочитатьЦелое32();
|
||||||
ЧтениеДанных.Закрыть();
|
ЧтениеДанных.Закрыть();
|
||||||
|
|
||||||
ЗаписьДанных.ЗаписатьБуферДвоичныхДанных(ZipDD(CRC32, РазмерСжатыхДанных, РазмерНесжатыхДанных));
|
ЗаписьДанных.ЗаписатьБуферДвоичныхДанных(ZipDD(CRC32 , РазмерСжатыхДанных, РазмерНесжатыхДанных));
|
||||||
ЗаписьДанных.ЗаписатьБуферДвоичныхДанных(ZipCDH(CRC32, РазмерСжатыхДанных, РазмерНесжатыхДанных));
|
ЗаписьДанных.ЗаписатьБуферДвоичныхДанных(ZipCDH(CRC32, РазмерСжатыхДанных, РазмерНесжатыхДанных));
|
||||||
ЗаписьДанных.ЗаписатьБуферДвоичныхДанных(ZipEOCD(РазмерСжатыхДанных));
|
ЗаписьДанных.ЗаписатьБуферДвоичныхДанных(ZipEOCD(РазмерСжатыхДанных));
|
||||||
ЗаписьДанных.Закрыть();
|
ЗаписьДанных.Закрыть();
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// OneScript: ./OInt/tests/Modules/internal/OPI_Тесты.os
|
// OneScript: ./OInt/tests/Modules/internal/OPI_Тесты.os
|
||||||
|
|
||||||
// MIT License
|
// MIT License
|
||||||
|
|
||||||
|
@ -82,6 +82,16 @@
|
|||||||
НоваяСтрока.Область = "Общие методы";
|
НоваяСтрока.Область = "Общие методы";
|
||||||
|
|
||||||
|
|
||||||
|
НоваяСтрока = ТаблицаСостава.Добавить();
|
||||||
|
НоваяСтрока.Библиотека = "s3";
|
||||||
|
НоваяСтрока.Модуль = "OPI_S3";
|
||||||
|
НоваяСтрока.Метод = "ОтправитьЗапросБезТела";
|
||||||
|
НоваяСтрока.МетодПоиска = "ОТПРАВИТЬЗАПРОСБЕЗТЕЛА";
|
||||||
|
НоваяСтрока.Параметр = "--binary";
|
||||||
|
НоваяСтрока.Описание = "Отключает попытку преобразования ответа в JSON (необяз. по ум. - Нет)";
|
||||||
|
НоваяСтрока.Область = "Общие методы";
|
||||||
|
|
||||||
|
|
||||||
НоваяСтрока = ТаблицаСостава.Добавить();
|
НоваяСтрока = ТаблицаСостава.Добавить();
|
||||||
НоваяСтрока.Библиотека = "s3";
|
НоваяСтрока.Библиотека = "s3";
|
||||||
НоваяСтрока.Модуль = "OPI_S3";
|
НоваяСтрока.Модуль = "OPI_S3";
|
||||||
@ -123,6 +133,16 @@
|
|||||||
НоваяСтрока.Область = "Общие методы";
|
НоваяСтрока.Область = "Общие методы";
|
||||||
|
|
||||||
|
|
||||||
|
НоваяСтрока = ТаблицаСостава.Добавить();
|
||||||
|
НоваяСтрока.Библиотека = "s3";
|
||||||
|
НоваяСтрока.Модуль = "OPI_S3";
|
||||||
|
НоваяСтрока.Метод = "ОтправитьЗапросСТелом";
|
||||||
|
НоваяСтрока.МетодПоиска = "ОТПРАВИТЬЗАПРОССТЕЛОМ";
|
||||||
|
НоваяСтрока.Параметр = "--binary";
|
||||||
|
НоваяСтрока.Описание = "Отключает попытку преобразования ответа в JSON (необяз. по ум. - Нет)";
|
||||||
|
НоваяСтрока.Область = "Общие методы";
|
||||||
|
|
||||||
|
|
||||||
НоваяСтрока = ТаблицаСостава.Добавить();
|
НоваяСтрока = ТаблицаСостава.Добавить();
|
||||||
НоваяСтрока.Библиотека = "s3";
|
НоваяСтрока.Библиотека = "s3";
|
||||||
НоваяСтрока.Модуль = "OPI_S3";
|
НоваяСтрока.Модуль = "OPI_S3";
|
||||||
@ -787,6 +807,77 @@
|
|||||||
НоваяСтрока.Область = "Работа с объектами";
|
НоваяСтрока.Область = "Работа с объектами";
|
||||||
|
|
||||||
|
|
||||||
|
НоваяСтрока = ТаблицаСостава.Добавить();
|
||||||
|
НоваяСтрока.Библиотека = "s3";
|
||||||
|
НоваяСтрока.Модуль = "OPI_S3";
|
||||||
|
НоваяСтрока.Метод = "ПолучитьОбъект";
|
||||||
|
НоваяСтрока.МетодПоиска = "ПОЛУЧИТЬОБЪЕКТ";
|
||||||
|
НоваяСтрока.Параметр = "--name";
|
||||||
|
НоваяСтрока.Описание = "Наименование объекта в бакете";
|
||||||
|
НоваяСтрока.Область = "Работа с объектами";
|
||||||
|
НоваяСтрока.ОписаниеМетода = "Получает содержимое объекта из бакета";
|
||||||
|
|
||||||
|
|
||||||
|
НоваяСтрока = ТаблицаСостава.Добавить();
|
||||||
|
НоваяСтрока.Библиотека = "s3";
|
||||||
|
НоваяСтрока.Модуль = "OPI_S3";
|
||||||
|
НоваяСтрока.Метод = "ПолучитьОбъект";
|
||||||
|
НоваяСтрока.МетодПоиска = "ПОЛУЧИТЬОБЪЕКТ";
|
||||||
|
НоваяСтрока.Параметр = "--bucket";
|
||||||
|
НоваяСтрока.Описание = "Имя бакета, в котором находится объект";
|
||||||
|
НоваяСтрока.Область = "Работа с объектами";
|
||||||
|
|
||||||
|
|
||||||
|
НоваяСтрока = ТаблицаСостава.Добавить();
|
||||||
|
НоваяСтрока.Библиотека = "s3";
|
||||||
|
НоваяСтрока.Модуль = "OPI_S3";
|
||||||
|
НоваяСтрока.Метод = "ПолучитьОбъект";
|
||||||
|
НоваяСтрока.МетодПоиска = "ПОЛУЧИТЬОБЪЕКТ";
|
||||||
|
НоваяСтрока.Параметр = "--basic";
|
||||||
|
НоваяСтрока.Описание = "Основные данные запроса. См. ПолучитьСтруктуруДанных";
|
||||||
|
НоваяСтрока.Область = "Работа с объектами";
|
||||||
|
|
||||||
|
|
||||||
|
НоваяСтрока = ТаблицаСостава.Добавить();
|
||||||
|
НоваяСтрока.Библиотека = "s3";
|
||||||
|
НоваяСтрока.Модуль = "OPI_S3";
|
||||||
|
НоваяСтрока.Метод = "ПолучитьОбъект";
|
||||||
|
НоваяСтрока.МетодПоиска = "ПОЛУЧИТЬОБЪЕКТ";
|
||||||
|
НоваяСтрока.Параметр = "--dir";
|
||||||
|
НоваяСтрока.Описание = "Истина > Directory Bucket, Ложь > General Purpose Bucket";
|
||||||
|
НоваяСтрока.Область = "Работа с объектами";
|
||||||
|
|
||||||
|
|
||||||
|
НоваяСтрока = ТаблицаСостава.Добавить();
|
||||||
|
НоваяСтрока.Библиотека = "s3";
|
||||||
|
НоваяСтрока.Модуль = "OPI_S3";
|
||||||
|
НоваяСтрока.Метод = "ПолучитьОбъект";
|
||||||
|
НоваяСтрока.МетодПоиска = "ПОЛУЧИТЬОБЪЕКТ";
|
||||||
|
НоваяСтрока.Параметр = "--ver";
|
||||||
|
НоваяСтрока.Описание = "Токен для получения конкретной версии объекта (необяз. по ум. - Пустое значение)";
|
||||||
|
НоваяСтрока.Область = "Работа с объектами";
|
||||||
|
|
||||||
|
|
||||||
|
НоваяСтрока = ТаблицаСостава.Добавить();
|
||||||
|
НоваяСтрока.Библиотека = "s3";
|
||||||
|
НоваяСтрока.Модуль = "OPI_S3";
|
||||||
|
НоваяСтрока.Метод = "ПолучитьОбъект";
|
||||||
|
НоваяСтрока.МетодПоиска = "ПОЛУЧИТЬОБЪЕКТ";
|
||||||
|
НоваяСтрока.Параметр = "--headers";
|
||||||
|
НоваяСтрока.Описание = "Дополнительные заголовки запроса, если необходимо (необяз. по ум. - Пустое значение)";
|
||||||
|
НоваяСтрока.Область = "Работа с объектами";
|
||||||
|
|
||||||
|
|
||||||
|
НоваяСтрока = ТаблицаСостава.Добавить();
|
||||||
|
НоваяСтрока.Библиотека = "s3";
|
||||||
|
НоваяСтрока.Модуль = "OPI_S3";
|
||||||
|
НоваяСтрока.Метод = "ПолучитьОбъект";
|
||||||
|
НоваяСтрока.МетодПоиска = "ПОЛУЧИТЬОБЪЕКТ";
|
||||||
|
НоваяСтрока.Параметр = "--out";
|
||||||
|
НоваяСтрока.Описание = "Путь для прямой записи файла на диск (необяз. по ум. - Пустое значение)";
|
||||||
|
НоваяСтрока.Область = "Работа с объектами";
|
||||||
|
|
||||||
|
|
||||||
НоваяСтрока = ТаблицаСостава.Добавить();
|
НоваяСтрока = ТаблицаСостава.Добавить();
|
||||||
НоваяСтрока.Библиотека = "s3";
|
НоваяСтрока.Библиотека = "s3";
|
||||||
НоваяСтрока.Модуль = "OPI_S3";
|
НоваяСтрока.Модуль = "OPI_S3";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user