Customer Portal
You do not currently have any active features or valid keys assigned to your account. Please contact an administrator.
You are logged in with an S3 Storage key. Please login with an AI Image API key (kikaku_xxx) to access this feature.
Quota Used
-
- / -
Remaining
-
Success Rate
-
Avg Response
-
Generated image will appear here
Loading gallery...
| ID | Model | Status | Response Time | Timestamp | Error |
|---|---|---|---|---|---|
| Click "Filter" to load logs | |||||
SeedDream 4.5 / 4.0 Image Generation API β Panduan Lengkap & Referensi
API ini adalah gateway ke model SeedDream untuk generate gambar berkualitas tinggi dari teks dan/atau gambar referensi.
Didukung oleh model seedream-4-5-251128 dan
seedream-4-0-250828.
πΌοΈ Multi-Mode Generation
Text-to-image, image-to-image, multi-image blending, dan batch generation dalam satu endpoint
π Flexible Resolution
Pilih preset (1K/2K/4K) atau custom pixel (WxH). Model otomatis menentukan aspect ratio sesuai prompt
β‘ Batch & Fallback
Generate hingga 15 gambar sekaligus. Jika model return kurang dari yang diminta, fallback otomatis dijalankan
Setiap request harus menyertakan API key di header Authorization. Key berformat kikaku_XXXXXXX untuk AI Image, atau kikaku_s3_XXXXXXX untuk S3 Storage.
Authorization: Bearer kikaku_YOUR_API_KEY
Endpoint utama untuk generate gambar. Mendukung text-to-image, image-to-image, multi-image blending, dan batch generation.
| Parameter | Type | Required | Default | Penjelasan Detail |
|---|---|---|---|---|
| model | string | Required | β |
Model yang digunakan untuk generate gambar. Pilihan: β’ seedream-4.5 β Model terbaru, kualitas lebih tinggi, mendukung resolusi 2K & 4K. Mode prompt optimization hanya standard.β’ seedream-4.0 β Model stabil, mendukung 1K/2K/4K. Mendukung mode fast untuk generate lebih cepat dengan trade-off kualitas.
|
| prompt | string | Required | β |
Deskripsi teks untuk gambar yang ingin di-generate. Maks 10.000 karakter, disarankan <600 kata bahasa Inggris. Tips: Gunakan bahasa natural yang koheren β deskripsikan subjek + aksi + environment. Jika estetika penting, tambahkan deskripsi style, warna, pencahayaan, atau komposisi. Contoh bagus: "Vibrant close-up editorial portrait, model with piercing gaze, wearing a sculptural hat, rich color blocking, sharp focus on eyes, shallow depth of field, Vogue magazine cover aesthetic" Peringatan: Prompt terlalu panjang bisa membuat model kehilangan fokus pada detail tertentu. |
| image | string | string[] | Optional | β |
Gambar referensi untuk image-to-image atau multi-image blending. Format input: β’ URL β URL yang bisa diakses publik, contoh: https://example.com/photo.jpgβ’ Base64 β Format: data:image/jpeg;base64,/9j/4AAQ...Single image: Kirim sebagai string biasa. Multi-image (2β14): Kirim sebagai array of strings. Dalam prompt, referensikan dengan "image 1", "image 2", dst. Batasan input: JPEG, PNG, WEBP, BMP, TIFF, GIF β maks 10MB per gambar β aspect ratio [1/16, 16] β min 14Γ14 px β maks 6000Γ6000 total pixel (36 juta px). |
| size | string | Optional | 2048x2048 |
Dimensi output gambar. Ada 2 metode (tidak bisa dipakai bersamaan): Metode 1 β Preset resolusi: Gunakan 2K atau 4K (4.5) / 1K, 2K, 4K (4.0). Model otomatis menentukan widthΓheight berdasarkan prompt. Deskripsikan aspect ratio di prompt, misal "poster portrait 3:4".Metode 2 β Custom pixel: Format WIDTHxHEIGHT, misal 2048x2048. Harus memenuhi: total pixel dalam range & aspect ratio [1/16, 16].
|
| response_format | string | Optional | "url" |
Format response gambar yang di-generate: β’ url β Return URL download gambar. URL berlaku 24 jam setelah generate, pastikan download/simpan sebelum expired.β’ b64_json β Return data gambar sebagai Base64 string dalam JSON. Berguna ketika ingin langsung embed tanpa download.
|
| watermark | boolean | Optional | true |
Apakah menambahkan watermark ke gambar output. β’ true β Menambahkan teks "AI generated" di pojok kanan bawah gambar.β’ false β Tidak ada watermark. Cocok untuk produksi/commercial use.
|
| sequential_image_generation | string | Optional | "disabled" |
Kontrol fitur batch (generate beberapa gambar sekaligus). β’ disabled β Hanya generate 1 gambar (default).β’ auto β Model otomatis menentukan jumlah gambar berdasarkan isi prompt. Misal, "generate 4 seasonal scenes..." β model akan coba generate 4.β οΈ Penting: Mode auto membuat model memutuskan sendiri berapa gambar yang dihasilkan. Jika prompt tidak eksplisit meminta multiple gambar, model mungkin hanya return 1. Sistem kami memiliki fallback otomatis: jika model return kurang dari max_images, request tambahan akan dibuat secara paralel.
|
| sequential_image_generation_options.max_images | integer | Optional | 15 |
Jumlah maksimum gambar yang di-generate dalam satu request batch. Range: 1β15. Constraint: Jumlah gambar referensi (input) + jumlah gambar output β€ 15. Misal, jika kirim 3 gambar referensi, maka max_images efektif = 12. Hanya berlaku ketika sequential_image_generation = "auto".
|
| optimize_prompt_options.mode | string | Optional | "standard" |
Mode optimisasi prompt sebelum generate dilakukan. β’ standard β Kualitas lebih tinggi, waktu generate lebih lama. Didukung semua model.β’ fast β Generate lebih cepat, tapi kualitas gambar rata-rata lebih rendah. Hanya untuk seedream-4.0.Use case fast mode: Preview/draft cepat, iterasi prompt, situasi di mana kecepatan lebih penting dari kualitas akhir. |
| n | integer | Legacy | 1 |
Parameter legacy untuk backward-compatibility. Jumlah gambar yang ingin di-generate (1β15). Jika n > 1 dan sequential_image_generation tidak diset, sistem otomatis mengkonversi ke:sequential_image_generation: "auto" +
max_images: n.Rekomendasi: Gunakan sequential_image_generation + max_images secara eksplisit untuk kontrol penuh.
|
Semua response menggunakan format JSON. Output gambar selalu dalam format JPEG untuk kedua model (4.5 & 4.0).
// β
Success Response
{
"model": "seedream-4-5-251128",
"created": 1757323224,
"data": [
{
"url": "https://ark-..../image-001.jpeg", // jika response_format = "url"
"size": "1760x2368" // dimensi aktual output
},
{
"b64_json": "/9j/4AAQSkZJRgABAQ...", // jika response_format = "b64_json"
"size": "2048x2048"
}
],
"usage": {
"generated_images": 1, // jumlah gambar yang berhasil di-generate
"output_tokens": 16280, // token cost (width*height/256)
"total_tokens": 16280
}
}
// β Error Response (top-level)
{
"error": {
"code": "InvalidParameter",
"message": "Invalid size \"5K\". Use 2K/4K or WIDTHxHEIGHT"
}
}
// β οΈ Partial Error (dalam batch β satu gambar gagal, lainnya berhasil)
{
"data": [
{ "url": "https://...", "size": "2048x2048" },
{ "error": { "code": "ContentFilter", "message": "Image rejected by content filter" } }
]
}
data adalah array β bahkan untuk single image, tetap array dengan 1 elemen.data[].size berformat "WxH" pixel (misal "2048x2048"), menunjukkan dimensi aktual gambar.usage.output_tokens dihitung per gambar: β(width Γ height) / 256β. Billing berdasarkan gambar yang berhasil saja.Berikan instruksi teks yang jelas dan akurat. Model akan generate gambar berkualitas tinggi yang sesuai deskripsi. Tidak perlu parameter image.
curl -X POST YOUR_BASE_URL/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer kikaku_YOUR_KEY" \
-d '{
"model": "seedream-4.5",
"prompt": "Vibrant close-up editorial portrait, model with piercing gaze, wearing a sculptural hat, rich color blocking, sharp focus on eyes, shallow depth of field, Vogue magazine cover aesthetic, dramatic studio lighting",
"size": "2K",
"response_format": "url",
"watermark": false
}'
Kirim 1 gambar referensi + instruksi perubahan melalui prompt. Cocok untuk menambah/hapus elemen, ubah style/tekstur, ganti background, adjust warna, atau ubah perspektif.
curl -X POST YOUR_BASE_URL/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer kikaku_YOUR_KEY" \
-d '{
"model": "seedream-4.5",
"prompt": "Keep the model pose unchanged. Change the clothing material from silver metal to completely transparent clear water. Through the liquid, the skin details are visible. Lighting changes from reflection to refraction.",
"image": "https://example.com/my-photo.jpg",
"size": "2K",
"watermark": false
}'
Kirim 2β14 gambar referensi sebagai array. Referensikan dengan "image 1", "image 2", dst. dalam prompt. Contoh use case: combine baju dari foto A ke model di foto B, merge style dari beberapa gambar, virtual try-on.
curl -X POST YOUR_BASE_URL/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer kikaku_YOUR_KEY" \
-d '{
"model": "seedream-4.5",
"prompt": "Replace the clothing in image 1 with the outfit from image 2. Keep the original pose and background.",
"image": [
"https://example.com/model-photo.jpg",
"https://example.com/outfit-photo.jpg"
],
"size": "2K",
"sequential_image_generation": "disabled",
"watermark": false
}'
Generate kumpulan gambar tematik β misal storyboard film, visual branding, variasi seasonal. Set sequential_image_generation: "auto" dan tentukan max_images.
Tips: Sebutkan jumlah gambar dan deskripsi masing-masing secara eksplisit dalam prompt agar model tahu berapa gambar yang harus di-generate.
curl -X POST YOUR_BASE_URL/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer kikaku_YOUR_KEY" \
-d '{
"model": "seedream-4.5",
"prompt": "Generate 4 illustrations of the same courtyard across seasons: Scene 1 spring with cherry blossoms, Scene 2 summer with bright sunlight, Scene 3 autumn with falling leaves, Scene 4 winter with snow covering.",
"size": "2K",
"sequential_image_generation": "auto",
"sequential_image_generation_options": { "max_images": 4 },
"watermark": false
}'
Kirim 1 gambar referensi + prompt β generate beberapa gambar terkait. Misal: dari 1 logo generate visual system (packaging, hat, card, lanyard).
curl -X POST YOUR_BASE_URL/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer kikaku_YOUR_KEY" \
-d '{
"model": "seedream-4.5",
"prompt": "Using this LOGO as reference, create a visual design system for an outdoor sports brand named GREEN, including packaging bags, hats, cards, lanyards. Main tone is green, fun, simple, modern style.",
"image": "https://example.com/my-logo.png",
"size": "2K",
"sequential_image_generation": "auto",
"sequential_image_generation_options": { "max_images": 4 },
"watermark": false
}'
Kirim 2+ gambar referensi + batch mode β generate set gambar yang konsisten dengan kedua referensi. Misal: karakter + objek β generate variasi scene.
curl -X POST YOUR_BASE_URL/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer kikaku_YOUR_KEY" \
-d '{
"model": "seedream-4.5",
"prompt": "Generate 3 images of a girl and a cow plushie happily riding a roller coaster, depicting morning, noon, and night scenes.",
"image": [
"https://example.com/girl-character.png",
"https://example.com/cow-plushie.png"
],
"sequential_image_generation": "auto",
"sequential_image_generation_options": { "max_images": 3 },
"size": "2K",
"watermark": false
}'
Gunakan optimize_prompt_options.mode: "fast" untuk generate lebih cepat. Trade-off: kualitas gambar sedikit lebih rendah dari mode standard. Hanya tersedia di seedream-4.0.
curl -X POST YOUR_BASE_URL/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer kikaku_YOUR_KEY" \
-d '{
"model": "seedream-4.0",
"prompt": "Generate 4 coherent illustrations of a courtyard across four seasons, unified style capturing unique colors and atmosphere of each season.",
"size": "2K",
"sequential_image_generation": "auto",
"sequential_image_generation_options": { "max_images": 4 },
"optimize_prompt_options": { "mode": "fast" },
"watermark": false
}'
n Parameter β Backward CompatibilityJika masih menggunakan parameter n, sistem otomatis mengkonversi ke batch mode. Tapi disarankan gunakan sequential_image_generation secara eksplisit.
curl -X POST YOUR_BASE_URL/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer kikaku_YOUR_KEY" \
-d '{
"model": "seedream-4.5",
"prompt": "A cute cat in different poses: sitting, jumping, sleeping",
"n": 3,
"size": "2K",
"watermark": false
}'
// β Secara internal dikonversi menjadi:
// sequential_image_generation: "auto", max_images: 3
Dua metode sizing tersedia. Jangan gunakan keduanya bersamaan.
Pilih resolusi (1K/2K/4K), lalu deskripsikan aspect ratio/bentuk/tujuan di prompt. Model otomatis menentukan widthΓheight.
Tentukan widthΓheight eksak dalam pixel. Harus memenuhi total pixel range DAN aspect ratio [1/16, 16].
| Resolution | 1:1 | 4:3 | 3:4 | 16:9 | 9:16 | 3:2 | 2:3 | 21:9 |
|---|---|---|---|---|---|---|---|---|
| 2K | 2048Γ2048 | 2304Γ1728 | 1728Γ2304 | 2848Γ1600 | 1600Γ2848 | 2496Γ1664 | 1664Γ2496 | 3136Γ1344 |
| 4K | 4096Γ4096 | 4704Γ3520 | 3520Γ4704 | 5504Γ3040 | 3040Γ5504 | 4992Γ3328 | 3328Γ4992 | 6240Γ2656 |
Pixel range: [2560Γ1440 = 3,686,400 , 4096Γ4096 = 16,777,216]
| Resolution | 1:1 | 4:3 | 3:4 | 16:9 | 9:16 | 3:2 | 2:3 | 21:9 |
|---|---|---|---|---|---|---|---|---|
| 1K | 1024Γ1024 | 1152Γ864 | 864Γ1152 | 1312Γ736 | 736Γ1312 | 1248Γ832 | 832Γ1248 | 1568Γ672 |
| 2K | 2048Γ2048 | 2304Γ1728 | 1728Γ2304 | 2848Γ1600 | 1600Γ2848 | 2496Γ1664 | 1664Γ2496 | 3136Γ1344 |
| 4K | 4096Γ4096 | 4704Γ3520 | 3520Γ4704 | 5504Γ3040 | 3040Γ5504 | 4992Γ3328 | 3328Γ4992 | 6240Γ2656 |
Pixel range: [1280Γ720 = 921,600 , 4096Γ4096 = 16,777,216]
Tabel lengkap perbandingan fitur antara kedua model yang didukung.
| Fitur | seedream-4.5 | seedream-4.0 |
|---|---|---|
| Model ID (internal) | seedream-4-5-251128 | seedream-4-0-250828 |
| Text to Image | β Didukung | β Didukung |
| Single Image β Image | β Didukung | β Didukung |
| Multi-Image Blending | β Hingga 14 referensi | β Hingga 14 referensi |
| Text β Batch Images | β Hingga 15 output | β Hingga 15 output |
| Image β Batch Images | β Input+output β€ 15 | β Input+output β€ 15 |
| Multi-Image β Batch Images | β Input+output β€ 15 | β Input+output β€ 15 |
| Resolusi yang Didukung | 2K 4K | 1K 2K 4K |
| Output Format | JPEG only (tidak bisa custom) | JPEG only (tidak bisa custom) |
| Prompt Optimization | standard | standard fast |
| Max Gambar per Menit | 500 | 500 |
| Max Referensi Input | 14 gambar | 14 gambar |
| Watermark | β Bisa on/off | β Bisa on/off |
Menampilkan informasi quota, jumlah pemakaian, sisa quota, status key, dan statistik request (total, sukses, gagal, rata-rata response time).
curl -H "Authorization: Bearer kikaku_YOUR_KEY" YOUR_BASE_URL/v1/usage
// Response:
{
"owner_name": "John Doe",
"email": "[email protected]",
"quota_limit": 1000,
"used_count": 42,
"remaining": 958,
"status": "active",
"created_at": "2025-01-15T10:00:00Z",
"expires_at": "2026-01-15T10:00:00Z",
"stats": {
"total_requests": 50,
"successful_requests": 42,
"failed_requests": 8,
"avg_response_time_ms": 3200
}
}
Query parameters:
| Param | Type | Keterangan |
|---|---|---|
| start_date | string | Filter mulai tanggal (ISO format), misal: 2025-01-01 |
| end_date | string | Filter sampai tanggal |
| page | integer | Halaman (default: 1) |
| limit | integer | Jumlah per halaman (default: 20, maks: 100) |
curl -H "Authorization: Bearer kikaku_YOUR_KEY" \
"YOUR_BASE_URL/v1/logs?start_date=2025-01-01&end_date=2025-12-31&page=1&limit=20"
// Response:
{
"logs": [
{
"id": 123,
"model": "seedream-4.5",
"timestamp": "2025-06-15T14:30:00Z",
"status": "success",
"response_time_ms": 2800,
"error_message": null
}
],
"pagination": { "page": 1, "limit": 20, "total": 150 }
}
Semua gambar yang berhasil di-generate otomatis disimpan ke S3 storage dan bisa di-browse lewat endpoint ini. Query parameters:
| Param | Type | Keterangan |
|---|---|---|
| page | integer | Halaman (default: 1) |
| limit | integer | Jumlah per halaman (default: 20, maks: 100) |
curl -H "Authorization: Bearer kikaku_YOUR_KEY" \
"YOUR_BASE_URL/v1/gallery?page=1&limit=20"
// Response:
{
"images": [
{
"id": 456,
"prompt": "A magical forest with glowing mushrooms",
"model": "seedream-4.5",
"s3_url": "https://s3.onidel.com/bucket/path/image.jpeg",
"image_size": "2K",
"created_at": "2025-06-15T14:30:05Z"
}
],
"pagination": { "page": 1, "limit": 20, "total": 42 }
}
| Batasan | Nilai | Detail |
|---|---|---|
| Format yang didukung | JPEG, PNG, WEBP, BMP, TIFF, GIF | Semua format umum. GIF diambil frame pertama. |
| Ukuran file | Maks 10 MB per gambar | Kompresi dulu jika melebihi limit. |
| Dimensi minimum | 14 Γ 14 pixel | Width dan height harus > 14px. |
| Total pixel maksimum | 6000 Γ 6000 = 36 juta px | Dihitung dari WΓH (bukan per dimensi). |
| Aspect ratio | [1/16, 16] | Ratio W/H harus antara 1/16 s.d. 16. |
| Jumlah gambar referensi | Maks 14 gambar | Untuk multi-image blending / batch generation. |
| Input + Output total | β€ 15 | Jumlah gambar referensi + jumlah gambar output tidak boleh melebihi 15. |
| Base64 format | data:image/jpeg;base64,... | Prefix wajib, format gambar lowercase. |
| Code | Arti | Cara Mengatasi |
|---|---|---|
200 | Success | Request berhasil. Gambar tersedia di data[]. |
400 | Bad Request | Parameter tidak valid. Periksa model, size, format image, dan semua field yang dikirim. |
401 | Unauthorized | API key tidak valid atau tidak ada. Pastikan format header benar: Bearer kikaku_xxx. |
403 | Forbidden | Key suspended, expired, atau quota habis. Hubungi admin untuk perpanjangan. |
429 | Rate Limit | Terlalu banyak request. Tunggu sebentar lalu coba lagi. Rate limit: 10 req/menit per key. |
500 | Server Error | Error internal. Coba lagi. Jika terus terjadi, hubungi support. |
timeout | Request Timeout | Request melebihi 120 detik. Coba kurangi resolusi atau jumlah batch. |
π Rate Limits
πΎ Penyimpanan & Expiry
GET /v1/galleryπ Batch Fallback
auto membuat model sendiri yang tentukan jumlah outputmax_images, sistem buat request tambahan paralelπ Prompt Tips
You are logged in with an AI Image key. Please login with an S3 Storage API key (kikaku_s3_xxx) to access this feature.
Storage Used
-
- / -
Remaining
-
Status
-
Uploading...
| Name | Size | Last Modified | Actions |
|---|---|---|---|
| Loading files... | |||
Use these credentials with any S3-compatible tool (AWS CLI, boto3, aws-sdk, etc.)
-
-
-
-
-
# Configure
aws configure set aws_access_key_id YOUR_ACCESS_KEY
aws configure set aws_secret_access_key YOUR_SECRET_KEY
aws configure set default.region YOUR_REGION
# List files
aws s3 ls s3://YOUR_BUCKET --endpoint-url YOUR_ENDPOINT
# Upload file
aws s3 cp myfile.txt s3://YOUR_BUCKET/myfile.txt --endpoint-url YOUR_ENDPOINT
# Download file
aws s3 cp s3://YOUR_BUCKET/myfile.txt ./myfile.txt --endpoint-url YOUR_ENDPOINT
import boto3
s3 = boto3.client('s3',
endpoint_url='YOUR_ENDPOINT',
aws_access_key_id='YOUR_ACCESS_KEY',
aws_secret_access_key='YOUR_SECRET_KEY',
region_name='YOUR_REGION')
# Upload
s3.upload_file('myfile.txt', 'YOUR_BUCKET', 'myfile.txt')
# Download
s3.download_file('YOUR_BUCKET', 'myfile.txt', './myfile.txt')
# List
response = s3.list_objects_v2(Bucket='YOUR_BUCKET')
for obj in response.get('Contents', []):
print(obj['Key'], obj['Size'])
const { S3Client, PutObjectCommand, ListObjectsV2Command } = require('@aws-sdk/client-s3');
const fs = require('fs');
const s3 = new S3Client({
endpoint: 'YOUR_ENDPOINT',
region: 'YOUR_REGION',
credentials: {
accessKeyId: 'YOUR_ACCESS_KEY',
secretAccessKey: 'YOUR_SECRET_KEY',
},
forcePathStyle: true,
});
// Upload
await s3.send(new PutObjectCommand({
Bucket: 'YOUR_BUCKET',
Key: 'myfile.txt',
Body: fs.readFileSync('myfile.txt'),
}));
// List
const { Contents } = await s3.send(new ListObjectsV2Command({
Bucket: 'YOUR_BUCKET',
}));
Contents.forEach(obj => console.log(obj.Key, obj.Size));
All requests use your API key for authentication. Files are proxied through our server with quota enforcement.
Include your API key in every request:
Authorization: Bearer kikaku_s3_YOUR_API_KEY
Upload a file. Use multipart/form-data with field file. Optional key field for custom path.
curl -X POST YOUR_BASE_URL/s3/upload \
-H "Authorization: Bearer YOUR_S3_KEY" \
-F "[email protected]" \
-F "key=folder/myfile.txt"
List files in your bucket. Optional query params: prefix, limit, cursor.
curl -H "Authorization: Bearer YOUR_S3_KEY" \
YOUR_BASE_URL/s3/files?prefix=folder/&limit=50
Download a file by its key.
curl -H "Authorization: Bearer YOUR_S3_KEY" \
YOUR_BASE_URL/s3/files/folder/myfile.txt -o myfile.txt
Delete a file. Freed storage is reclaimed from your quota.
curl -X DELETE -H "Authorization: Bearer YOUR_S3_KEY" \
YOUR_BASE_URL/s3/files/folder/myfile.txt
Check your storage quota and usage.
curl -H "Authorization: Bearer YOUR_S3_KEY" \
YOUR_BASE_URL/s3/usage
401 β Invalid/missing API key403 β Key suspended, expired, or quota exceeded404 β File not found429 β Rate limit exceededconst fs = require('fs');
const FormData = require('form-data');
const axios = require('axios');
const API_KEY = 'YOUR_S3_KEY';
const BASE = 'YOUR_BASE_URL';
// Upload
const form = new FormData();
form.append('file', fs.createReadStream('photo.jpg'));
form.append('key', 'images/photo.jpg');
await axios.post(`${BASE}/s3/upload`, form, {
headers: { ...form.getHeaders(), Authorization: `Bearer ${API_KEY}` }
});
// List files
const { data } = await axios.get(`${BASE}/s3/files`, {
headers: { Authorization: `Bearer ${API_KEY}` }
});
console.log(data.files);
// Download
const resp = await axios.get(`${BASE}/s3/files/images/photo.jpg`, {
headers: { Authorization: `Bearer ${API_KEY}` },
responseType: 'stream'
});
resp.data.pipe(fs.createWriteStream('downloaded.jpg'));
import requests
API_KEY = 'YOUR_S3_KEY'
BASE = 'YOUR_BASE_URL'
headers = {'Authorization': f'Bearer {API_KEY}'}
# Upload
with open('photo.jpg', 'rb') as f:
resp = requests.post(f'{BASE}/s3/upload',
headers=headers,
files={'file': f},
data={'key': 'images/photo.jpg'})
print(resp.json())
# List files
resp = requests.get(f'{BASE}/s3/files', headers=headers)
for f in resp.json()['files']:
print(f['key'], f['size'])
# Download
resp = requests.get(f'{BASE}/s3/files/images/photo.jpg',
headers=headers, stream=True)
with open('downloaded.jpg', 'wb') as f:
for chunk in resp.iter_content(8192):
f.write(chunk)