Upload media library file
Uploads a file to the media library and returns the created media library entry.
curl --request POST \
--url https://your_a2_service/media_library \
--header 'Content-Type: multipart/form-data' \
--form 'cdn_host=<string>' \
--form file='@example-file' \
--form file_size=123 \
--form height=123 \
--form 'mime=<string>' \
--form owner_id=3c90c3cc-0d44-4b50-8888-8dd25736052a \
--form 'storage=<string>' \
--form width=123import requests
url = "https://your_a2_service/media_library"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = {
"cdn_host": "<string>",
"file_size": "123",
"height": "123",
"mime": "<string>",
"owner_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"storage": "<string>",
"width": "123"
}
response = requests.post(url, data=payload, files=files)
print(response.text)const form = new FormData();
form.append('cdn_host', '<string>');
form.append('file', '<string>');
form.append('file_size', '123');
form.append('height', '123');
form.append('mime', '<string>');
form.append('owner_id', '3c90c3cc-0d44-4b50-8888-8dd25736052a');
form.append('storage', '<string>');
form.append('width', '123');
const options = {method: 'POST'};
options.body = form;
fetch('https://your_a2_service/media_library', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your_a2_service/media_library",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cdn_host\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_size\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mime\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"owner_id\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"storage\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your_a2_service/media_library"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cdn_host\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_size\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mime\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"owner_id\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"storage\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://your_a2_service/media_library")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cdn_host\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_size\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mime\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"owner_id\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"storage\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://your_a2_service/media_library")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cdn_host\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_size\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mime\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"owner_id\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"storage\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"cdn_path": "<string>",
"file_size": 123,
"filename": "<string>",
"height": 123,
"mime": "<string>",
"no": 123,
"path": "<string>",
"storage": "<string>",
"user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"width": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"detail": "<string>"
}Body
The base URL of the CDN where the media will be accessible
The media file to be uploaded to the library
The size of the file in bytes
The height of the media in pixels
The MIME type of the media file (e.g., image/jpeg, video/mp4)
The owner's id of media library
The storage backend where the media will be stored. Supported values: 'fs' (filesystem) or 'aws' (Amazon Web Services)
The width of the media in pixels
Response
Successful Response
Schema for reading media library entity.
The CDN url from which the media can be accessed
The file size of the media
The filename of media library
The height of the media
The mime-type of the media
The no of media library
Relative paths stored in the storage
The storage type where the media is stored
The owner's id of media library
The width of the media
The date and time the entity was created.
The date and time the entity was last updated.
Was this page helpful?
curl --request POST \
--url https://your_a2_service/media_library \
--header 'Content-Type: multipart/form-data' \
--form 'cdn_host=<string>' \
--form file='@example-file' \
--form file_size=123 \
--form height=123 \
--form 'mime=<string>' \
--form owner_id=3c90c3cc-0d44-4b50-8888-8dd25736052a \
--form 'storage=<string>' \
--form width=123import requests
url = "https://your_a2_service/media_library"
files = { "file": ("example-file", open("example-file", "rb")) }
payload = {
"cdn_host": "<string>",
"file_size": "123",
"height": "123",
"mime": "<string>",
"owner_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"storage": "<string>",
"width": "123"
}
response = requests.post(url, data=payload, files=files)
print(response.text)const form = new FormData();
form.append('cdn_host', '<string>');
form.append('file', '<string>');
form.append('file_size', '123');
form.append('height', '123');
form.append('mime', '<string>');
form.append('owner_id', '3c90c3cc-0d44-4b50-8888-8dd25736052a');
form.append('storage', '<string>');
form.append('width', '123');
const options = {method: 'POST'};
options.body = form;
fetch('https://your_a2_service/media_library', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://your_a2_service/media_library",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cdn_host\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_size\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mime\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"owner_id\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"storage\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Content-Type: multipart/form-data"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://your_a2_service/media_library"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cdn_host\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_size\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mime\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"owner_id\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"storage\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://your_a2_service/media_library")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cdn_host\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_size\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mime\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"owner_id\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"storage\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://your_a2_service/media_library")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cdn_host\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file_size\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"height\"\r\n\r\n123\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mime\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"owner_id\"\r\n\r\n3c90c3cc-0d44-4b50-8888-8dd25736052a\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"storage\"\r\n\r\n<string>\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"width\"\r\n\r\n123\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"cdn_path": "<string>",
"file_size": 123,
"filename": "<string>",
"height": 123,
"mime": "<string>",
"no": 123,
"path": "<string>",
"storage": "<string>",
"user_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"width": 123,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"detail": "<string>"
}