curl -X PUT "https://mybucket.storage.nami.cloud/example.jpg" \
-H "Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20231028/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-date, Signature=fe5f80f77d5fa3beca038a248ff027d0445342fe2855ddc963176630326f1024" \
-H "Content-Type: image/jpeg" \
-H "Content-Length: 11434" \
--data-binary "@example.jpg"
import boto3
s3_client = boto3.client('s3',
endpoint_url='https://storage.nami.cloud',
aws_access_key_id='YOUR_ACCESS_KEY',
aws_secret_access_key='YOUR_SECRET_KEY'
)
with open('example.jpg', 'rb') as file:
s3_client.put_object(
Bucket='mybucket',
Key='example.jpg',
Body=file,
ContentType='image/jpeg'
)
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
import { readFileSync } from "fs";
const client = new S3Client({
endpoint: "https://storage.nami.cloud",
credentials: {
accessKeyId: "YOUR_ACCESS_KEY",
secretAccessKey: "YOUR_SECRET_KEY",
},
});
async function uploadFile() {
const fileContent = readFileSync('example.jpg');
const command = new PutObjectCommand({
Bucket: "mybucket",
Key: "example.jpg",
Body: fileContent,
ContentType: "image/jpeg"
});
try {
const response = await client.send(command);
console.log("업로드 성공:", response);
} catch (err) {
console.error("오류:", err);
}
}
uploadFile();
package main
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"os"
)
func main() {
sess := session.Must(session.NewSession(&aws.Config{
Endpoint: aws.String("https://storage.nami.cloud"),
Region: aws.String("us-east-1"),
Credentials: credentials.NewStaticCredentials("YOUR_ACCESS_KEY", "YOUR_SECRET_KEY", ""),
}))
s3Client := s3.New(sess)
file, err := os.Open("example.jpg")
if err != nil {
panic(err)
}
defer file.Close()
_, err = s3Client.PutObject(&s3.PutObjectInput{
Bucket: aws.String("mybucket"),
Key: aws.String("example.jpg"),
Body: file,
ContentType: aws.String("image/jpeg"),
})
if err != nil {
panic(err)
}
}
use aws_sdk_s3::{Client, Config};
use aws_config::credentials::StaticCredentialsProvider;
use aws_types::region::Region;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let credentials = StaticCredentialsProvider::new(
"YOUR_ACCESS_KEY".to_string(),
"YOUR_SECRET_KEY".to_string(),
None,
);
let config = Config::builder()
.endpoint_url("https://storage.nami.cloud")
.region(Region::new("us-east-1"))
.credentials_provider(credentials)
.build();
let client = Client::from_conf(config);
let body = aws_sdk_s3::types::ByteStream::from_path("example.jpg").await?;
client
.put_object()
.bucket("mybucket")
.key("example.jpg")
.body(body)
.content_type("image/jpeg")
.send()
.await?;
println!("업로드 성공!");
Ok(())
}
{
"Code": "<string>",
"Message": "<string>",
"RequestId": "<string>"
}객체 작업
객체 업로드
버킷에 객체를 업로드합니다.
PUT
/
curl -X PUT "https://mybucket.storage.nami.cloud/example.jpg" \
-H "Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20231028/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-date, Signature=fe5f80f77d5fa3beca038a248ff027d0445342fe2855ddc963176630326f1024" \
-H "Content-Type: image/jpeg" \
-H "Content-Length: 11434" \
--data-binary "@example.jpg"
import boto3
s3_client = boto3.client('s3',
endpoint_url='https://storage.nami.cloud',
aws_access_key_id='YOUR_ACCESS_KEY',
aws_secret_access_key='YOUR_SECRET_KEY'
)
with open('example.jpg', 'rb') as file:
s3_client.put_object(
Bucket='mybucket',
Key='example.jpg',
Body=file,
ContentType='image/jpeg'
)
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
import { readFileSync } from "fs";
const client = new S3Client({
endpoint: "https://storage.nami.cloud",
credentials: {
accessKeyId: "YOUR_ACCESS_KEY",
secretAccessKey: "YOUR_SECRET_KEY",
},
});
async function uploadFile() {
const fileContent = readFileSync('example.jpg');
const command = new PutObjectCommand({
Bucket: "mybucket",
Key: "example.jpg",
Body: fileContent,
ContentType: "image/jpeg"
});
try {
const response = await client.send(command);
console.log("업로드 성공:", response);
} catch (err) {
console.error("오류:", err);
}
}
uploadFile();
package main
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"os"
)
func main() {
sess := session.Must(session.NewSession(&aws.Config{
Endpoint: aws.String("https://storage.nami.cloud"),
Region: aws.String("us-east-1"),
Credentials: credentials.NewStaticCredentials("YOUR_ACCESS_KEY", "YOUR_SECRET_KEY", ""),
}))
s3Client := s3.New(sess)
file, err := os.Open("example.jpg")
if err != nil {
panic(err)
}
defer file.Close()
_, err = s3Client.PutObject(&s3.PutObjectInput{
Bucket: aws.String("mybucket"),
Key: aws.String("example.jpg"),
Body: file,
ContentType: aws.String("image/jpeg"),
})
if err != nil {
panic(err)
}
}
use aws_sdk_s3::{Client, Config};
use aws_config::credentials::StaticCredentialsProvider;
use aws_types::region::Region;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let credentials = StaticCredentialsProvider::new(
"YOUR_ACCESS_KEY".to_string(),
"YOUR_SECRET_KEY".to_string(),
None,
);
let config = Config::builder()
.endpoint_url("https://storage.nami.cloud")
.region(Region::new("us-east-1"))
.credentials_provider(credentials)
.build();
let client = Client::from_conf(config);
let body = aws_sdk_s3::types::ByteStream::from_path("example.jpg").await?;
client
.put_object()
.bucket("mybucket")
.key("example.jpg")
.body(body)
.content_type("image/jpeg")
.send()
.await?;
println!("업로드 성공!");
Ok(())
}
{
"Code": "<string>",
"Message": "<string>",
"RequestId": "<string>"
}버킷에 대한 쓰기 권한이 있는지 확인하세요.
객체 업로드
버킷에 객체를 추가합니다. 객체 데이터는 요청 본문에 전송됩니다.기본 URL
https://${bucketname}.storage.nami.cloud
매개변수
생성할 객체의 키
헤더
객체의 크기(바이트)
Content-Type
객체 데이터의 형식을 설명하는 표준 MIME 타입
x-amz-storage-class
객체 저장에 사용할 스토리지 클래스
요청 예제
curl -X PUT "https://mybucket.storage.nami.cloud/example.jpg" \
-H "Authorization: AWS4-HMAC-SHA256 Credential=AKIAIOSFODNN7EXAMPLE/20231028/us-east-1/s3/aws4_request, SignedHeaders=host;x-amz-date, Signature=fe5f80f77d5fa3beca038a248ff027d0445342fe2855ddc963176630326f1024" \
-H "Content-Type: image/jpeg" \
-H "Content-Length: 11434" \
--data-binary "@example.jpg"
import boto3
s3_client = boto3.client('s3',
endpoint_url='https://storage.nami.cloud',
aws_access_key_id='YOUR_ACCESS_KEY',
aws_secret_access_key='YOUR_SECRET_KEY'
)
with open('example.jpg', 'rb') as file:
s3_client.put_object(
Bucket='mybucket',
Key='example.jpg',
Body=file,
ContentType='image/jpeg'
)
import { S3Client, PutObjectCommand } from "@aws-sdk/client-s3";
import { readFileSync } from "fs";
const client = new S3Client({
endpoint: "https://storage.nami.cloud",
credentials: {
accessKeyId: "YOUR_ACCESS_KEY",
secretAccessKey: "YOUR_SECRET_KEY",
},
});
async function uploadFile() {
const fileContent = readFileSync('example.jpg');
const command = new PutObjectCommand({
Bucket: "mybucket",
Key: "example.jpg",
Body: fileContent,
ContentType: "image/jpeg"
});
try {
const response = await client.send(command);
console.log("업로드 성공:", response);
} catch (err) {
console.error("오류:", err);
}
}
uploadFile();
package main
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"os"
)
func main() {
sess := session.Must(session.NewSession(&aws.Config{
Endpoint: aws.String("https://storage.nami.cloud"),
Region: aws.String("us-east-1"),
Credentials: credentials.NewStaticCredentials("YOUR_ACCESS_KEY", "YOUR_SECRET_KEY", ""),
}))
s3Client := s3.New(sess)
file, err := os.Open("example.jpg")
if err != nil {
panic(err)
}
defer file.Close()
_, err = s3Client.PutObject(&s3.PutObjectInput{
Bucket: aws.String("mybucket"),
Key: aws.String("example.jpg"),
Body: file,
ContentType: aws.String("image/jpeg"),
})
if err != nil {
panic(err)
}
}
use aws_sdk_s3::{Client, Config};
use aws_config::credentials::StaticCredentialsProvider;
use aws_types::region::Region;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let credentials = StaticCredentialsProvider::new(
"YOUR_ACCESS_KEY".to_string(),
"YOUR_SECRET_KEY".to_string(),
None,
);
let config = Config::builder()
.endpoint_url("https://storage.nami.cloud")
.region(Region::new("us-east-1"))
.credentials_provider(credentials)
.build();
let client = Client::from_conf(config);
let body = aws_sdk_s3::types::ByteStream::from_path("example.jpg").await?;
client
.put_object()
.bucket("mybucket")
.key("example.jpg")
.body(body)
.content_type("image/jpeg")
.send()
.await?;
println!("업로드 성공!");
Ok(())
}
응답 예제
HTTP/1.1 200 OK
x-amz-id-2: YgIPIfBiKa2bj0KMgUAdQkf3ShJTOOpXUueF6QKo
x-amz-request-id: 236A8905248E5A01
Date: Wed, 28 Oct 2023 22:32:00 GMT
ETag: "6805f2cfc46c0f04559748bb039d69ae"
Content-Length: 0
Server: Nami Cloud
⌘I