NAV
PHP cURL JS Golang Python Ruby

شروع

سایدکار ای پی آی اختصاصی پشتیبان بر روی پارتیشن s3-compatible پشتیبان است که امکانات بسیار زیادی را به این سرویس اضافه می‌کند.

این امکانات استثنایی بر روی تمام پارتیشن‌های S3 در دسترس هستند.

راهنمای ساخت پارتیشن

آدرس API

آدرس API به صورت زیر خواهد بود:

https://YOUR_S3_ENDPOINT/sidecar

برای اطلاع از endpoint پارتیشن خود ابتدا وارد پنل کاربری خود در سایت پشتیبان شوید. از منوی پارتیشن‌های S3 پارتیشن مورد نظر خود را انتخاب کنید. سپس در زبانه آدرس‌ها در بخش اندپوینت S3 می‌توانید اندپوینت خود را مشاهده کنید

احراز هویت

برای احراز هویت درخواست‌های خود باید ابتدا کلید دسترسی و کلید خصوصی پارتیشن را از پنل کاربری خود دریافت کنید.

تمامی درخواست‌های وب سرویس به سرور باید دارای Header مشابه زیر باشند:

Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY

اطلاعات پایه

اندپوینت‌های این گروه اطلاعات جامعی درباره پارتیشن را در اختیار شما خواهند گذاشت.

مشاهده فضای مصرف شده

عبارت‌های YOUR_S3_ENDPOINT و SIDECAR_ACCESS_KEY و SIDECAR_SECRET_KEY را با مقادیر مختص پارتیشن خود جایگزین کنید

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://YOUR_S3_ENDPOINT/sidecar/du",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

curl --location --request GET 'https://YOUR_S3_ENDPOINT/sidecar/du' \
--header 'Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY'
var myHeaders = new Headers();
myHeaders.append("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://YOUR_S3_ENDPOINT/sidecar/du", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://YOUR_S3_ENDPOINT/sidecar/du"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
import http.client
import mimetypes
conn = http.client.HTTPSConnection("https://YOUR_S3_ENDPOINT/sidecar")
payload = ''
headers = {
  'Authorization': 'SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY'
}
conn.request("GET", "/du", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"

url = URI("https://YOUR_S3_ENDPOINT/sidecar/du")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"

response = https.request(request)
puts response.read_body

پاسخ اندپوینت بالا به صورت زیر خواهد بود:

{
    "used": 54874068
}

این اندپوینت کد فضای مصرف شده پارتیشن با بر می‌گرداند

درخواست HTTP

GET http://YOUR_S3_ENDPOINT/sidecar/du

پهنای باند مصرفی

فایل‌های فشرده

با استفاده از اندپوینت‌های این بخش می‌توانید بر روی فایل‌های فشرده (zip) عملیات مختلفی انجام دهید

ایجاد فایل فشرده

عبارت‌های YOUR_S3_ENDPOINT و YOUR_S3_ENDPOINT را با مقادیر مختص پارتیشن خود جایگزین کنید

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://YOUR_S3_ENDPOINT/sidecar/archive/create",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"sources\": [\n            \"/personal/file.jpg\",\n            \"/movies/2020\"\n        ],\n    \"password\": \"\",\n    \"bucket\": \"archives\",\n    \"destination\": \"movies/2020\",\n    \"source\": \"all.zip\"\n}",
  CURLOPT_HTTPHEADER => array(
    "Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


curl --location --request POST 'https://YOUR_S3_ENDPOINT/sidecar/archive/create' \
--header 'Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "sources": [
            "/personal/file.jpg",
            "/movies/2020"
        ],
    "password": "",
    "bucket": "archives",
    "destination": "movies/2020",
    "source": "all.zip"
}'
var myHeaders = new Headers();
myHeaders.append("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"sources":["/personal/file.jpg","/movies/2020"],"password":"","bucket":"archives","destination":"movies/2020","source":"all.zip"});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://YOUR_S3_ENDPOINT/sidecar/archive/create", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://YOUR_S3_ENDPOINT/sidecar/archive/create"
  method := "POST"

  payload := strings.NewReader("{\n    \"sources\": [\n            \"/personal/file.jpg\",\n            \"/movies/2020\"\n        ],\n    \"password\": \"\",\n    \"bucket\": \"archives\",\n    \"destination\": \"movies/2020\",\n    \"source\": \"all.zip\"\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
import http.client
import mimetypes
conn = http.client.HTTPSConnection("https://YOUR_S3_ENDPOINT/sidecar")
payload = "{\n    \"sources\": [\n            \"/personal/file.jpg\",\n            \"/movies/2020\"\n        ],\n    \"password\": \"\",\n    \"bucket\": \"archives\",\n    \"destination\": \"movies/2020\",\n    \"source\": \"all.zip\"\n}"
headers = {
  'Authorization': 'SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY',
  'Content-Type': 'application/json'
}
conn.request("POST", "/archive/create", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"

url = URI("https://YOUR_S3_ENDPOINT/sidecar/archive/create")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"
request["Content-Type"] = "application/json"
request.body = "{\n    \"sources\": [\n            \"/personal/file.jpg\",\n            \"/movies/2020\"\n        ],\n    \"password\": \"\",\n    \"bucket\": \"archives\",\n    \"destination\": \"movies/2020\",\n    \"source\": \"all.zip\"\n}"

response = https.request(request)
puts response.read_body

پاسخ اندپوینت بالا به صورت زیر خواهد بود:

{
    "created_at": "2020-09-20T09:50:52.66096835Z",
    "id": "5f6725fc7cec895e11d1df0e",
    "private_data": {
        "Sources": [
            "/personal/file.jpg",
            "/movies/2020"
        ],
        "Password": "",
        "Bucket": "archives",
        "Destination": "movies/2020",
        "Source": "all.zip"
    },
    "status": "pending",
    "type": "CREATE_ARCHIVE",
    "updated_at": "2020-09-20T09:50:52.66096835Z"
}

با استفاده از این اندپوینت می‌توانید فایل‌های مختلف روی پارتیشن خود را زیپ کرده و بر روی باکت مورد نظر ذخیره کنید.

درخواست HTTP

POST http://YOUR_S3_ENDPOINT/archive/create

پارامترهای Body

Parameter Type Mandatory Default Description
sources Array true - فهرست فایل‌های یا دایرکتوری‌های مورد نظر برای اضافه شدن به فایل فشرده
bucket String true - نام باکتی که فایل فشرده باید در آن ذخیره شود
source String true - نام فایل فشرده
destination String false - فهرستی جدا شده با / از دایرکتوری‌های داخل باکت جهت ذخیره شده فایل فشرده در این مسیر
password String false - رمز عبور فایل فشرده

هر درخواست ساخت فایل فشرده به صورت یک job در سیستم ثبت خواهد شد. برای مشاهده وضعیت عملیات باید وضعیت جاب مورد نظر را بررسی نمایید.

آنزیپ کردن فایل فشرده

عبارت‌های YOUR_S3_ENDPOINT و SIDECAR_ACCESS_KEY و SIDECAR_SECRET_KEY را با مقادیر مختص پارتیشن خود جایگزین کنید

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://YOUR_S3_ENDPOINT/sidecar/archive/extract",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"objects\": [\n       \n        {\n            \"source\": \"/archives/movies/2020/all.zip\",\n            \"password\": \"123\",\n            \"bucket\": \"movies\",\n            \"destination\": \"2020\"\n        }\n    ]\n}",
  CURLOPT_HTTPHEADER => array(
    "Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

curl --location --request POST 'https://YOUR_S3_ENDPOINT/sidecar/archive/extract' \
--header 'Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "objects": [

        {
            "source": "/archives/movies/2020/all.zip",
            "password": "123",
            "bucket": "movies",
            "destination": "2020"
        }
    ]
}'
var myHeaders = new Headers();
myHeaders.append("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"objects":[{"source":"/archives/movies/2020/all.zip","password":"123","bucket":"movies","destination":"2020"}]});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://YOUR_S3_ENDPOINT/sidecar/archive/extract", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://YOUR_S3_ENDPOINT/sidecar/archive/extract"
  method := "POST"

  payload := strings.NewReader("{\n    \"objects\": [\n       \n        {\n            \"source\": \"/archives/movies/2020/all.zip\",\n            \"password\": \"123\",\n            \"bucket\": \"movies\",\n            \"destination\": \"2020\"\n        }\n    ]\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
import http.client
import mimetypes
conn = http.client.HTTPSConnection("https://YOUR_S3_ENDPOINT/sidecar")
payload = "{\n    \"objects\": [\n       \n        {\n            \"source\": \"/archives/movies/2020/all.zip\",\n            \"password\": \"123\",\n            \"bucket\": \"movies\",\n            \"destination\": \"2020\"\n        }\n    ]\n}"
headers = {
  'Authorization': 'SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY',
  'Content-Type': 'application/json'
}
conn.request("POST", "/archive/extract", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"

url = URI("https://YOUR_S3_ENDPOINT/sidecar/archive/extract")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"
request["Content-Type"] = "application/json"
request.body = "{\n    \"objects\": [\n       \n        {\n            \"source\": \"/archives/movies/2020/all.zip\",\n            \"password\": \"123\",\n            \"bucket\": \"movies\",\n            \"destination\": \"2020\"\n        }\n    ]\n}"

response = https.request(request)
puts response.read_body

پاسخ اندپوینت بالا به صورت زیر خواهد بود:

[
    {
        "action": "EXTRACT_ARCHIVE",
        "body": {
            "Object": "/mojtaba/2.zip",
            "Password": "",
            "Bucket": "wordpress",
            "Prefix": "folder/besaz"
        },
        "created_at": 1598858346,
        "id": "5f4ca46aa16b115d5f0040cc",
        "status": "pending",
        "updated_at": 1598858346
    },
    {
        "error": "/mojtaba/mojtaba.jpg is not a zip file"
    },
    {
        "action": "EXTRACT_ARCHIVE",
        "body": {
            "Object": "/mojtaba/4.zip",
            "Password": "123",
            "Bucket": "wordpress",
            "Prefix": ""
        },
        "created_at": 1598858346,
        "id": "5f4ca46aa16b115d5f0040cd",
        "status": "pending",
        "updated_at": 1598858346
    }
]

با استفاده از این اندپوینت می‌توانید فایل‌های مختلف روی پارتیشن خود را زیپ کرده و بر روی باکت مورد نظر ذخیره کنید.

درخواست HTTP

POST http://YOUR_S3_ENDPOINT/archive/extract

پارامترهای Body

Parameter Type Mandatory Default Description
objects Array true - آرایه‌ای از آبجکت فایل فشرده

آبجکت فایل فشرده

Name Mandatory Description Example
source String مسیر فایل فشرده بر روی پارتیشن (نام باکت باید ابتدای مسیر قرار بگیرد) /archives/movies/2020/all.zip
bucket String باکت مورد نظر جهت ذخیره سازی فایل‌های اکسترکت شده movies
destination String فهرستی جدا شده با / از دایرکتوری‌های داخل باکت جهت ذخیره شده فایل فشرده در این مسیر extracted/2020
password String رمز عبور فایل زیپ در صورت وجود داشتن 123

هر درخواست اکسترکت کردن فایل فشرده به صورت یک job در سیستم ثبت خواهد شد. برای مشاهده وضعیت عملیات باید وضعیت جاب مورد نظر را بررسی نمایید.

جاب‌ها

اندپوینت‌های این بخش به منظور کنترل جاب‌های سیستم استفاده می‌شوند

فهرست جاب‌ها

عبارت‌های YOUR_S3_ENDPOINT و SIDECAR_ACCESS_KEY و SIDECAR_SECRET_KEY را با مقادیر مختص پارتیشن خود جایگزین کنید

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "http://YOUR_S3_ENDPOINT/sidecar/job?page=1&per-page=100",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

curl --location --request GET 'http://YOUR_S3_ENDPOINT/sidecar/job?page=1&per-page=100' \
--header 'Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY'
var myHeaders = new Headers();
myHeaders.append("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("http://YOUR_S3_ENDPOINT/sidecar/job?page=1&per-page=100", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "http://YOUR_S3_ENDPOINT/sidecar/job?page=1&per-page=100"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
import http.client
import mimetypes
conn = http.client.HTTPSConnection("http://YOUR_S3_ENDPOINT/sidecar")
payload = ''
headers = {
  'Authorization': 'SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY'
}
conn.request("GET", "/job?page=1&per-page=100", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"

url = URI("http://YOUR_S3_ENDPOINT/sidecar/job?page=1&per-page=100")

http = Net::HTTP.new(url.host, url.port);
request = Net::HTTP::Get.new(url)
request["Authorization"] = "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"

response = http.request(request)
puts response.read_body

پاسخ اندپوینت بالا به صورت زیر خواهد بود:

[
    {
        "id": "5f6725ed7cec895e11d1df0d",
        "type": "CREATE_ARCHIVE",
        "status": "completed",
        "resource_type": "File",
        "data": null,
        "resource": {
            "bucket": "film",
            "etag": "e192d32133be102ef600217e780fbbfb",
            "expiration": "0001-01-01T00:00:00Z",
            "expirationruleid": "",
            "key": "rtl.zip",
            "lastmodified": "0001-01-01T00:00:00Z",
            "location": "",
            "size": 3790,
            "versionid": ""
        },
        "created_at": "2020-09-20T09:50:37.081Z",
        "updated_at": "2020-09-20T09:50:40.605Z"
    },
    {
        "id": "5f6725fc7cec895e11d1df0e",
        "type": "CREATE_ARCHIVE",
        "status": "downloading",
        "resource_type": "File",
        "data": null,
        "resource": null,
        "created_at": "2020-09-20T09:50:52.66Z",
        "updated_at": "2020-09-20T09:50:54.093Z"
    }
]

این اندپوینت لیستی از همه جاب‌های سیستم را باز می‌گرداند

درخواست HTTP

GET http://YOUR_S3_ENDPOINT/sidecar/job

Query Parameters

پارامتر مقدار پیش‌فرض توضیح
page 1 شماره صفحه مورد نظر جهت گرفتن لیست جاب‌ها
per-page 10 تعداد جاب در هرصفحه

دریافت یک جاب مشخص

عبارت‌های YOUR_S3_ENDPOINT و SIDECAR_ACCESS_KEY و SIDECAR_SECRET_KEY را با مقادیر مختص پارتیشن خود جایگزین کنید

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://YOUR_S3_ENDPOINT/sidecar/job/5f477206f802df2790f5d0d4",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
curl --location --request GET 'https://YOUR_S3_ENDPOINT/sidecar/job/5f477206f802df2790f5d0d4' \
--header 'Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY' \
--data-raw ''
var myHeaders = new Headers();
myHeaders.append("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY");

var raw = "";

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://YOUR_S3_ENDPOINT/sidecar/job/5f477206f802df2790f5d0d4", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://YOUR_S3_ENDPOINT/sidecar/job/5f477206f802df2790f5d0d4"
  method := "GET"

  payload := strings.NewReader("")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
import http.client
import mimetypes
conn = http.client.HTTPSConnection("https://YOUR_S3_ENDPOINT/sidecar")
payload = ''
headers = {
  'Authorization': 'SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY'
}
conn.request("GET", "/job/5f477206f802df2790f5d0d4", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"

url = URI("https://YOUR_S3_ENDPOINT/sidecar/job/5f477206f802df2790f5d0d4")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"

response = https.request(request)
puts response.read_body

پاسخ اندپوینت بالا به صورت زیر خواهد بود:

{
    "id": "5f6725fc7cec895e11d1df0e",
    "type": "CREATE_ARCHIVE",
    "status": "completed",
    "resource_type": "File",
    "data": null,
    "resource": {
        "bucket": "film",
        "etag": "8bbf49d56198ed16d72241a7385cbf78-25",
        "expiration": "0001-01-01T00:00:00Z",
        "expirationruleid": "",
        "key": "all.zip",
        "lastmodified": "0001-01-01T00:00:00Z",
        "size": 3259239386,
        "versionid": ""
    },
    "created_at": "2020-09-20T09:50:52.66Z",
    "updated_at": "2020-09-20T09:55:48.331Z"
}

این اندپوینت یک جاب مشخص را باز می‌گرداند

درخواست HTTP

GET http://YOUR_S3_ENDPOINT/sidecar/job/<id>

بروزرسانی یک جاب

عبارت‌های YOUR_S3_ENDPOINT و SIDECAR_ACCESS_KEY و SIDECAR_SECRET_KEY را با مقادیر مختص پارتیشن خود جایگزین کنید

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://YOUR_S3_ENDPOINT/sidecar/job/5f4ccb79a36d78adaa147bdc",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PATCH",
  CURLOPT_POSTFIELDS =>"{\n    \"status\": \"stopped\"\n}",
  CURLOPT_HTTPHEADER => array(
    "Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

curl --location --request PATCH 'https://YOUR_S3_ENDPOINT/sidecar/job/5f4ccb79a36d78adaa147bdc' \
--header 'Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "status": "stopped"
}'
var myHeaders = new Headers();
myHeaders.append("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"status":"stopped"});

var requestOptions = {
  method: 'PATCH',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://YOUR_S3_ENDPOINT/sidecar/job/5f4ccb79a36d78adaa147bdc", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://YOUR_S3_ENDPOINT/sidecar/job/5f4ccb79a36d78adaa147bdc"
  method := "PATCH"

  payload := strings.NewReader("{\n    \"status\": \"stopped\"\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
import http.client
import mimetypes
conn = http.client.HTTPSConnection("https://YOUR_S3_ENDPOINT/sidecar")
payload = "{\n    \"status\": \"stopped\"\n}"
headers = {
  'Authorization': 'SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY',
  'Content-Type': 'application/json'
}
conn.request("PATCH", "/job/5f4ccb79a36d78adaa147bdc", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"

url = URI("https://YOUR_S3_ENDPOINT/sidecar/job/5f4ccb79a36d78adaa147bdc")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"
request["Content-Type"] = "application/json"
request.body = "{\n    \"status\": \"stopped\"\n}"

response = https.request(request)
puts response.read_body

پاسخ اندپوینت بالا به صورت زیر خواهد بود:

{
    "_id": "5f6723440accab2bd7b15196",
    "created_at": "2020-09-20T14:09:16.832+04:30",
    "data": null,
    "private_data": {
        "bucket": "film",
        "destination": "",
        "password": "",
        "source": "all.zip",
        "sources": null
    },
    "resource_type": "File",
    "status": "stopped",
    "type": "CREATE_ARCHIVE",
    "updated_at": "2020-09-20T14:09:17.233+04:30",
}

این اندپوینت یک جاب مشخص را بروزرسانی می‌گرداند

در حال حاضر تنها status جاب قادر بروزرسانی است

درخواست HTTP

PATCH http://YOUR_S3_ENDPOINT/sidecar/job/<id>

پارامترهای Body

پارامتر نوع توضیح
status String نام وضعیت جدید

حذف یک جاب

عبارت‌های YOUR_S3_ENDPOINT و SIDECAR_ACCESS_KEY و SIDECAR_SECRET_KEY را با مقادیر مختص پارتیشن خود جایگزین کنید

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://YOUR_S3_ENDPOINT/sidecar/job/5f4ccb79a36d78adaa147bdc",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "DELETE",
  CURLOPT_HTTPHEADER => array(
    "Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

curl --location --request DELETE 'https://YOUR_S3_ENDPOINT/sidecar/job/5f4ccb79a36d78adaa147bdc' \
--header 'Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY' \
--data-raw ''
var myHeaders = new Headers();
myHeaders.append("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY");

var raw = "";

var requestOptions = {
  method: 'DELETE',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://YOUR_S3_ENDPOINT/sidecar/job/5f4ccb79a36d78adaa147bdc", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://YOUR_S3_ENDPOINT/sidecar/job/5f4ccb79a36d78adaa147bdc"
  method := "DELETE"

  payload := strings.NewReader("")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
import http.client
import mimetypes
conn = http.client.HTTPSConnection("https://YOUR_S3_ENDPOINT/sidecar")
payload = ''
headers = {
  'Authorization': 'SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY'
}
conn.request("DELETE", "/job/5f4ccb79a36d78adaa147bdc", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"

url = URI("https://YOUR_S3_ENDPOINT/sidecar/job/5f4ccb79a36d78adaa147bdc")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Delete.new(url)
request["Authorization"] = "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"

response = https.request(request)
puts response.read_body

پاسخ اندپوینت بالا به صورت زیر خواهد بود:

{
    "_id": "5f477206f802df2790f5d0d4",
    "action": "REMOTE_UPLOAD",
    "createdat": 1598517766,
    "percent": "100.00",
    "status": "upload_completed",
    "updatedat": 1598517769
}

این اندپوینت وظیفه حذف جاب را برعهده دارد

درخواست HTTP

DELETE http://YOUR_S3_ENDPOINT/sidecar/job/<id>

ریموت آپلود

اندپوینت‌های این بخش به منظور مدیریت آپلود از آدرس بر روی باکت استفاده می‌شوند

بررسی وضعیت لینک‌های دانلود

عبارت‌های YOUR_S3_ENDPOINT و SIDECAR_ACCESS_KEY و SIDECAR_SECRET_KEY را با مقادیر مختص پارتیشن خود جایگزین کنید

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://YOUR_S3_ENDPOINT/sidecar/remote/check",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"urls\": [\n        {\n            \"url\": \"https://poshtiban.com/resources/5dc99e4eeaec3700091ff11a/5dcabb6aeaec3701a27760bc.png\"\n        },\n        {\n            \"url\": \"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png\"\n        }\n    ]\n}",
  CURLOPT_HTTPHEADER => array(
    "Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

curl --location --request POST 'https://YOUR_S3_ENDPOINT/sidecar/remote/check' \
--header 'Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "urls": [
        {
            "url": "https://poshtiban.com/resources/5dc99e4eeaec3700091ff11a/5dcabb6aeaec3701a27760bc.png"
        },
        {
            "url": "https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png"
        }
    ]
}'
var myHeaders = new Headers();
myHeaders.append("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"urls":[{"url":"https://poshtiban.com/resources/5dc99e4eeaec3700091ff11a/5dcabb6aeaec3701a27760bc.png"},{"url":"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png"}]});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://YOUR_S3_ENDPOINT/sidecar/remote/check", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://YOUR_S3_ENDPOINT/sidecar/remote/check"
  method := "POST"

  payload := strings.NewReader("{\n    \"urls\": [\n        {\n            \"url\": \"https://poshtiban.com/resources/5dc99e4eeaec3700091ff11a/5dcabb6aeaec3701a27760bc.png\"\n        },\n        {\n            \"url\": \"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png\"\n        }\n    ]\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
import http.client
import mimetypes
conn = http.client.HTTPSConnection("https://YOUR_S3_ENDPOINT/sidecar")
payload = "{\n    \"urls\": [\n        {\n            \"url\": \"https://poshtiban.com/resources/5dc99e4eeaec3700091ff11a/5dcabb6aeaec3701a27760bc.png\"\n        },\n        {\n            \"url\": \"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png\"\n        }\n    ]\n}"
headers = {
  'Authorization': 'SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY',
  'Content-Type': 'application/json'
}
conn.request("POST", "/remote/check", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"

url = URI("https://YOUR_S3_ENDPOINT/sidecar/remote/check")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"
request["Content-Type"] = "application/json"
request.body = "{\n    \"urls\": [\n        {\n            \"url\": \"https://poshtiban.com/resources/5dc99e4eeaec3700091ff11a/5dcabb6aeaec3701a27760bc.png\"\n        },\n        {\n            \"url\": \"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png\"\n        }\n    ]\n}"

response = https.request(request)
puts response.read_body

پاسخ اندپوینت بالا به صورت زیر خواهد بود:

[
    {
        "name": "5dcabb6aeaec3701a27760bc.png",
        "size": 8741,
        "status": 200,
        "url": "https://poshtiban.com/resources/5dc99e4eeaec3700091ff11a/5dcabb6aeaec3701a27760bc.png"
    },
    {
        "name": "5dcabe32eaec3701a277663b.png",
        "size": 32700,
        "status": 200,
        "url": "https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png"
    }
]

این اندپوینت فهرستی از لینک‌های دانلود را دریافت کرده و وضعیت، حجم و نام هر فایل را باز می‌گرداند.

درخواست HTTP

POST http://YOUR_S3_ENDPOINT/sidecar/remote/check

پارامترهای Body

پارامتر نوع توضیح
urls Array آرایه‌ای از لینک‌های دانلود

آپلود

عبارت‌های YOUR_S3_ENDPOINT و SIDECAR_ACCESS_KEY و SIDECAR_SECRET_KEY را با مقادیر مختص پارتیشن خود جایگزین کنید

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://YOUR_S3_ENDPOINT/sidecar/remote/upload",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"{\n    \"urls\": [\n       \n        {\n            \"url\": \"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png\"\n        },\n        {\n            \"url\": \"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png\"\n        }\n    ],\n    \"bucket\": \"film\",\n    \"object_prefix\": \"my-custom-directory\"\n}",
  CURLOPT_HTTPHEADER => array(
    "Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

curl --location --request POST 'https://YOUR_S3_ENDPOINT/sidecar/remote/upload' \
--header 'Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "urls": [

        {
            "url": "https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png"
        },
        {
            "url": "https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png"
        }
    ],
    "bucket": "film",
    "object_prefix": "my-custom-directory"
}'
var myHeaders = new Headers();
myHeaders.append("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({"urls":[{"url":"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png"},{"url":"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png"}],"bucket":"film","object_prefix":"my-custom-directory"});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://YOUR_S3_ENDPOINT/sidecar/remote/upload", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://YOUR_S3_ENDPOINT/sidecar/remote/upload"
  method := "POST"

  payload := strings.NewReader("{\n    \"urls\": [\n       \n        {\n            \"url\": \"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png\"\n        },\n        {\n            \"url\": \"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png\"\n        }\n    ],\n    \"bucket\": \"film\",\n    \"object_prefix\": \"my-custom-directory\"\n}")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
import http.client
import mimetypes
conn = http.client.HTTPSConnection("https://YOUR_S3_ENDPOINT/sidecar")
payload = "{\n    \"urls\": [\n       \n        {\n            \"url\": \"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png\"\n        },\n        {\n            \"url\": \"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png\"\n        }\n    ],\n    \"bucket\": \"film\",\n    \"object_prefix\": \"my-custom-directory\"\n}"
headers = {
  'Authorization': 'SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY',
  'Content-Type': 'application/json'
}
conn.request("POST", "/remote/upload", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"

url = URI("https://YOUR_S3_ENDPOINT/sidecar/remote/upload")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"
request["Content-Type"] = "application/json"
request.body = "{\n    \"urls\": [\n       \n        {\n            \"url\": \"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png\"\n        },\n        {\n            \"url\": \"https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png\"\n        }\n    ],\n    \"bucket\": \"film\",\n    \"object_prefix\": \"my-custom-directory\"\n}"

response = https.request(request)
puts response.read_body

پاسخ اندپوینت بالا به صورت زیر خواهد بود:

[
    {
        "action": "REMOTE_UPLOAD",
        "body": {
            "Url": "https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png",
            "Bucket": "film",
            "Prefix": "my-custom-directory"
        },
        "created_at": 1598875163,
        "id": "5f4ce61b9e28bf26600f1531",
        "status": "pending",
        "updated_at": 1598875163
    },
    {
        "action": "REMOTE_UPLOAD",
        "body": {
            "Url": "https://poshtiban.com/resources/5dc9cbb9eaec37000920270f/5dcabe32eaec3701a277663b.png",
            "Bucket": "film",
            "Prefix": "my-custom-directory"
        },
        "created_at": 1598875163,
        "id": "5f4ce61b9e28bf26600f1532",
        "status": "pending",
        "updated_at": 1598875163
    }
]

این اندپوینت فهرستی از لینک‌های دانلود را دریافت کرده و در باکت مشخص ذخیره می‌کند.

درخواست HTTP

POST http://YOUR_S3_ENDPOINT/sidecar/remote/upload

پارامترهای Body

پارامتر نوع توضیح
urls Array آرایه‌ای از لینک‌های دانلود
bucket String نام باکت مورد نظر جهت ذخیره سازی
object_prefix String فهرستی جدا شده با / از دایرکتوری‌های داخل باکت جهت ذخیره شده فایل فشرده در این مسیر

ویدیو

اندپوینت‌های این بخش به منظور ویرایش ویدیوهای موجود بر روی پارتیشن استفاده می‌شوند.

ایجاد اسکرین شات از ویدیو

عبارت‌های YOUR_S3_ENDPOINT و SIDECAR_ACCESS_KEY و SIDECAR_SECRET_KEY را با مقادیر مختص پارتیشن خود جایگزین کنید

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://YOUR_S3_ENDPOINT/sidecar/video/thumbnail",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS =>"[\n    {\n        \"file\": \"/video/file_example_MP4_1920_18MG.mp4\",\n        \"time\": 2400,\n        \"width\": 250,\n        \"height\": 300,\n        \"bucket\": \"video\",\n        \"prefix\": \"thumbnails\",\n        \"object\": \"250-300.jpg\"\n    },\n\n    {\n        \"file\": \"/video/file_example_MP4_1920_18MG.mp4\",\n        \"time\": 200,\n        \"width\": 1000,\n        \"height\": 1000,\n        \"bucket\": \"video\",\n        \"prefix\": \"thumbnails\",\n        \"object\": \"250-300.jpg\"\n    }\n]",
  CURLOPT_HTTPHEADER => array(
    "Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY",
    "Content-Type: application/json"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


curl --location --request POST 'https://YOUR_S3_ENDPOINT/sidecar/video/thumbnail' \
--header 'Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY' \
--header 'Content-Type: application/json' \
--data-raw '[
    {
        "file": "/video/file_example_MP4_1920_18MG.mp4",
        "time": 2400,
        "width": 250,
        "height": 300,
        "bucket": "video",
        "prefix": "thumbnails",
        "object": "250-300.jpg"
    },

    {
        "file": "/video/file_example_MP4_1920_18MG.mp4",
        "time": 200,
        "width": 1000,
        "height": 1000,
        "bucket": "video",
        "prefix": "thumbnails",
        "object": "250-300.jpg"
    }
]'
var myHeaders = new Headers();
myHeaders.append("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify([{"file":"/video/file_example_MP4_1920_18MG.mp4","time":2400,"width":250,"height":300,"bucket":"video","prefix":"thumbnails","object":"250-300.jpg"},{"file":"/video/file_example_MP4_1920_18MG.mp4","time":200,"width":1000,"height":1000,"bucket":"video","prefix":"thumbnails","object":"250-300.jpg"}]);

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://YOUR_S3_ENDPOINT/sidecar/video/thumbnail", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
package main

import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://YOUR_S3_ENDPOINT/sidecar/video/thumbnail"
  method := "POST"

  payload := strings.NewReader("[\n    {\n        \"file\": \"/video/file_example_MP4_1920_18MG.mp4\",\n        \"time\": 2400,\n        \"width\": 250,\n        \"height\": 300,\n        \"bucket\": \"video\",\n        \"prefix\": \"thumbnails\",\n        \"object\": \"250-300.jpg\"\n    },\n\n    {\n        \"file\": \"/video/file_example_MP4_1920_18MG.mp4\",\n        \"time\": 200,\n        \"width\": 1000,\n        \"height\": 1000,\n        \"bucket\": \"video\",\n        \"prefix\": \"thumbnails\",\n        \"object\": \"250-300.jpg\"\n    }\n]")

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
import http.client
import mimetypes
conn = http.client.HTTPSConnection("https://YOUR_S3_ENDPOINT/sidecar")
payload = "[\n    {\n        \"file\": \"/video/file_example_MP4_1920_18MG.mp4\",\n        \"time\": 2400,\n        \"width\": 250,\n        \"height\": 300,\n        \"bucket\": \"video\",\n        \"prefix\": \"thumbnails\",\n        \"object\": \"250-300.jpg\"\n    },\n\n    {\n        \"file\": \"/video/file_example_MP4_1920_18MG.mp4\",\n        \"time\": 200,\n        \"width\": 1000,\n        \"height\": 1000,\n        \"bucket\": \"video\",\n        \"prefix\": \"thumbnails\",\n        \"object\": \"250-300.jpg\"\n    }\n]"
headers = {
  'Authorization': 'SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY',
  'Content-Type': 'application/json'
}
conn.request("POST", "/video/thumbnail", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"

url = URI("https://YOUR_S3_ENDPOINT/sidecar/video/thumbnail")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"
request["Content-Type"] = "application/json"
request.body = "[\n    {\n        \"file\": \"/video/file_example_MP4_1920_18MG.mp4\",\n        \"time\": 2400,\n        \"width\": 250,\n        \"height\": 300,\n        \"bucket\": \"video\",\n        \"prefix\": \"thumbnails\",\n        \"object\": \"250-300.jpg\"\n    },\n\n    {\n        \"file\": \"/video/file_example_MP4_1920_18MG.mp4\",\n        \"time\": 200,\n        \"width\": 1000,\n        \"height\": 1000,\n        \"bucket\": \"video\",\n        \"prefix\": \"thumbnails\",\n        \"object\": \"250-300.jpg\"\n    }\n]"

response = https.request(request)
puts response.read_body

پاسخ اندپوینت بالا به صورت زیر خواهد بود:

[
    {
        "action": "GENERATE_VIDEO_THUMBNAIL",
        "body": {
            "File": "/video/file_example_MP4_1920_18MG.mp4",
            "Time": 2400,
            "Width": 250,
            "Height": 300,
            "Bucket": "video",
            "Prefix": "thumbnails",
            "Object": "250-300.jpg"
        },
        "created_at": 1598876106,
        "id": "5f4ce9caac3dc1668af3244b",
        "status": "pending",
        "updated_at": 1598876106
    },
    {
        "action": "GENERATE_VIDEO_THUMBNAIL",
        "body": {
            "File": "/video/file_example_MP4_1920_18MG.mp4",
            "Time": 200,
            "Width": 1000,
            "Height": 1000,
            "Bucket": "video",
            "Prefix": "thumbnails",
            "Object": "1000-1000.jpg"
        },
        "created_at": 1598876106,
        "id": "5f4ce9caac3dc1668af3244c",
        "status": "pending",
        "updated_at": 1598876106
    }
]

این اندپوینت اسکرین شاتی از ویدیو ایجاد می‌کند. و به صورت تصویر در مسیر مشخص شده ذخیره می‌کند

درخواست HTTP

POST http://YOUR_S3_ENDPOINT/sidecar/video/thumbnail

پارامترهای Body

بادی آرایه‌ای از آبجکت‌ها با ساختار زیر است

پارامتر نوع توضیح
file String مسیر فایل ویدیویی بر روی پارتیشن (نام باکت باید ابتدای مسیر قرار بگیرد)
time Integer زمان گرفتن اسکرین شات به ثانیه
width Integer عرض تصویر ایجاد شده
height Integer ارتفاع تصویر ایجاد شده
bucket String باکت مورد نظر جهت ذخیره سازی فایل‌های اکسترکت شده
prefix String فهرستی جدا شده با / از دایرکتوری‌های داخل باکت جهت ذخیره شده فایل فشرده در این مسیر
object String نام فایل

باکت

اندپوینت‌های این بخش به منظور مدیریت باکت‌های پارتیشن استفاده می‌شوند.

فهرست باکت‌ها

عبارت‌های YOUR_S3_ENDPOINT و SIDECAR_ACCESS_KEY و SIDECAR_SECRET_KEY را با مقادیر مختص پارتیشن خود جایگزین کنید

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://YOUR_S3_ENDPOINT/sidecar/bucket",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


curl --location --request GET 'https://YOUR_S3_ENDPOINT/sidecar/bucket' \
--header 'Authorization: SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY'
var myHeaders = new Headers();
myHeaders.append("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY");

var requestOptions = {
  method: 'GET',
  headers: myHeaders,
  redirect: 'follow'
};

fetch("https://YOUR_S3_ENDPOINT/sidecar/bucket", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
package main

import (
  "fmt"
  "net/http"
  "io/ioutil"
)

func main() {

  url := "https://YOUR_S3_ENDPOINT/sidecar/bucket"
  method := "GET"

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, nil)

  if err != nil {
    fmt.Println(err)
  }
  req.Header.Add("Authorization", "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY")

  res, err := client.Do(req)
  defer res.Body.Close()
  body, err := ioutil.ReadAll(res.Body)

  fmt.Println(string(body))
}
import http.client
import mimetypes
conn = http.client.HTTPSConnection("https://YOUR_S3_ENDPOINT/sidecar")
payload = ''
headers = {
  'Authorization': 'SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY'
}
conn.request("GET", "/bucket", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
require "uri"
require "net/http"

url = URI("https://YOUR_S3_ENDPOINT/sidecar/bucket")

https = Net::HTTP.new(url.host, url.port);
https.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "SIDECAR_ACCESS_KEY SIDECAR_SECRET_KEY"

response = https.request(request)
puts response.read_body

پاسخ اندپوینت بالا به صورت زیر خواهد بود:

[
    {
        "name": "amazon",
        "creationDate": "2020-08-17T05:04:22.083Z"
    },
    {
        "name": "film",
        "creationDate": "2020-08-04T06:00:04.1Z"
    },
    {
        "name": "mojtaba",
        "creationDate": "2020-08-04T05:38:49.199Z"
    },
    {
        "name": "music",
        "creationDate": "2020-08-04T05:38:52.614Z"
    },
    {
        "name": "video",
        "creationDate": "2020-08-26T03:57:19.191Z"
    },
    {
        "name": "wordpress",
        "creationDate": "2020-08-17T04:48:48.122Z"
    }
]

این اندپوینت فهرستی از باکت‌های موجود بر روی پارتیشن را باز می‌گرداند

درخواست HTTP

GET http://YOUR_S3_ENDPOINT/sidecar/bucket

خطاها

The Kittn API uses the following error codes:

Error Code Meaning
400 Bad Request -- Your request is invalid.
401 Unauthorized -- Your API key is wrong.
403 Forbidden -- The kitten requested is hidden for administrators only.
404 Not Found -- The specified kitten could not be found.
405 Method Not Allowed -- You tried to access a kitten with an invalid method.
406 Not Acceptable -- You requested a format that isn't json.
410 Gone -- The kitten requested has been removed from our servers.
418 I'm a teapot.
429 Too Many Requests -- You're requesting too many kittens! Slow down!
500 Internal Server Error -- We had a problem with our server. Try again later.
503 Service Unavailable -- We're temporarily offline for maintenance. Please try again later.