Enterprise: Update S3 Details Endpoint
- enterprise/system_details
- enterprise/restart_server
- enterprise/update_server
- enterprise/update_s3
- enterprise/clear_cache
- enterprise/schedulers_list
- enterprise/load_model
- enterprise/verify_model
- enterprise/get_all_models
- enterprise/delete_model
- enterprise/controlnet
- enterprise/text2img
- enterprise/text2video
- enterprise/text2video
- enterprise/inpaint
- enterprise/super_resolution
- enterprise/upload_image
- enterprise/sync_image
- enterprise/load_vae
- enterprise/nsfw_image_check
- enterprise/fetch_queue_image
Overview
This endpoint is used to update the S3 details on your dedicated server.
Request
--request POST 'https://stablediffusionapi.com/api/v1/enterprise/update_s3' \
Send a POST
request to https://stablediffusionapi.com/api/v1/enterprise/update_s3 endpoint. You have to pass the below listed request body parameters to update the S3 details.
info
You can use any S3 compatible service like Cloudflare R2, Digital Ocean Spaces, AWS S3, Google Cloud Storage, Alibaba OSS, Backblaze, etc.
danger
You need to give PutObjectAcl on S3 bucket. Else you won't be able to upload images to S3 bucket.
Here is link to stackoverflow on how to do it: https://stackoverflow.com/questions/36272286/getting-access-denied-when-calling-the-putobject-operation-with-bucket-level-per
Attributes
Parameter | Description |
---|---|
key | Your enterprise API Key used for request authorization. |
public_url | A public URL on which images can be accessible. Make sure to make your bucket publicly accessible, so you can access the links. |
region_name | S3 region name. |
endpoint_url | S3 endpoint URL. |
aws_access_key_id | Bucket's access key. |
aws_secret_access_key | Bucket's secret key. |
image_directory | The image directory inside the S3 bucket, where images will be stored. Create a directory named "generations" inside the bucket and make sure it is public, so you can access the images using their links. |
Example
Body
Body Raw
{
"key": "enterprise_api_key",
"public_url": "https://d1okzptojspljx.cloudfront.net/generations/",
"region_name": "us-east-1",
"endpoint_url": "https://stable-diffusion-api.s3.amazonaws.com",
"aws_access_key_id": "access-key",
"aws_secret_access_key": "secret-key",
"image_directory": "generations"
}
Request
- JS
- PHP
- NODE
- PYTHON
- JAVA
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"key": "",
"public_url": "https://d1okzptojspljx.cloudfront.net/generations/",
"region_name": "us-east-1",
"endpoint_url": "https://stable-diffusion-api.s3.amazonaws.com",
"aws_access_key_id": "access-key",
"aws_secret_access_key": "secret-key",
"image_directory": "generations"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://stablediffusionapi.com/api/v1/enterprise/update_s3", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "",
"public_url" => "https://d1okzptojspljx.cloudfront.net/generations/",
"region_name" => "us-east-1",
"endpoint_url" => "https://stable-diffusion-api.s3.amazonaws.com",
"aws_access_key_id" => "access-key",
"aws_secret_access_key" => "secret-key",
"image_directory" => "generations"
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://stablediffusionapi.com/api/v1/enterprise/update_s3',
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 => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://stablediffusionapi.com/api/v1/enterprise/update_s3',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "",
"public_url": "https://d1okzptojspljx.cloudfront.net/generations/",
"region_name": "us-east-1",
"endpoint_url": "https://stable-diffusion-api.s3.amazonaws.com",
"aws_access_key_id": "access-key",
"aws_secret_access_key": "secret-key",
"image_directory": "generations"
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "https://stablediffusionapi.com/api/v1/enterprise/update_s3"
payload = json.dumps({
"key": "",
"public_url": "https://d1okzptojspljx.cloudfront.net/generations/",
"region_name": "us-east-1",
"endpoint_url": "https://stable-diffusion-api.s3.amazonaws.com",
"aws_access_key_id": "access-key",
"aws_secret_access_key": "secret-key",
"image_directory": "generations"
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"key\": \"\",\n \"public_url\": \"https://d1okzptojspljx.cloudfront.net/generations/\",\n \"region_name\": \"us-east-1\",\n \"endpoint_url\": \"https://stable-diffusion-api.s3.amazonaws.com\",\n \"aws_access_key_id\": \"access-key\",\n \"aws_secret_access_key\": \"secret-key\",\n \"image_directory\": \"generations\"\n}");
Request request = new Request.Builder()
.url("https://stablediffusionapi.com/api/v1/enterprise/update_s3")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
Make sure to give below permissions to your IAM user to upload images on S3 bucket.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:PutObject",
"s3:GetObject",
"s3:PutObjectAcl"
],
"Resource": [
"arn:aws:s3:::stable-diffusion-api",
"arn:aws:s3:::stable-diffusion-api/*"
]
}
]
}