curl "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" \
--output 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'
)
s3_client.download_file(
Bucket='mybucket',
Key='example.jpg',
Filename='downloaded_example.jpg'
)
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
import { createWriteStream } from "fs";
const client = new S3Client({
endpoint: "https://storage.nami.cloud",
credentials: {
accessKeyId: "YOUR_ACCESS_KEY",
secretAccessKey: "YOUR_SECRET_KEY",
},
});
async function downloadFile() {
const command = new GetObjectCommand({
Bucket: "mybucket",
Key: "example.jpg",
});
try {
const response = await client.send(command);
const writeStream = createWriteStream('downloaded_example.jpg');
response.Body.pipe(writeStream);
} catch (err) {
console.error("エラー:", err);
}
}
downloadFile();
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.Create("downloaded_example.jpg")
if err != nil {
panic(err)
}
defer file.Close()
result, err := s3Client.GetObject(&s3.GetObjectInput{
Bucket: aws.String("mybucket"),
Key: aws.String("example.jpg"),
})
if err != nil {
panic(err)
}
defer result.Body.Close()
_, err = file.ReadFrom(result.Body)
if err != nil {
panic(err)
}
}
use aws_sdk_s3::{Client, Config};
use aws_config::credentials::StaticCredentialsProvider;
use aws_types::region::Region;
use tokio::fs::File;
use tokio::io::AsyncWriteExt;
#[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 response = client
.get_object()
.bucket("mybucket")
.key("example.jpg")
.send()
.await?;
let mut file = File::create("downloaded_example.jpg").await?;
let bytes = response.body.collect().await?.into_bytes();
file.write_all(&bytes).await?;
println!("ダウンロード成功!");
Ok(())
}
{
"Name": "<string>",
"Prefix": "<string>",
"MaxKeys": 123,
"IsTruncated": true,
"Contents": [
{
"Key": "<string>",
"LastModified": "2023-11-07T05:31:56Z",
"ETag": "<string>",
"Size": 123,
"StorageClass": "<string>"
}
]
}オブジェクトオペレーション
オブジェクトの取得
最先端のグローバルコンセンサスプロトコルと分散ストレージを用いたクラウドサービスの革新
GET
/
curl "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" \
--output 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'
)
s3_client.download_file(
Bucket='mybucket',
Key='example.jpg',
Filename='downloaded_example.jpg'
)
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
import { createWriteStream } from "fs";
const client = new S3Client({
endpoint: "https://storage.nami.cloud",
credentials: {
accessKeyId: "YOUR_ACCESS_KEY",
secretAccessKey: "YOUR_SECRET_KEY",
},
});
async function downloadFile() {
const command = new GetObjectCommand({
Bucket: "mybucket",
Key: "example.jpg",
});
try {
const response = await client.send(command);
const writeStream = createWriteStream('downloaded_example.jpg');
response.Body.pipe(writeStream);
} catch (err) {
console.error("エラー:", err);
}
}
downloadFile();
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.Create("downloaded_example.jpg")
if err != nil {
panic(err)
}
defer file.Close()
result, err := s3Client.GetObject(&s3.GetObjectInput{
Bucket: aws.String("mybucket"),
Key: aws.String("example.jpg"),
})
if err != nil {
panic(err)
}
defer result.Body.Close()
_, err = file.ReadFrom(result.Body)
if err != nil {
panic(err)
}
}
use aws_sdk_s3::{Client, Config};
use aws_config::credentials::StaticCredentialsProvider;
use aws_types::region::Region;
use tokio::fs::File;
use tokio::io::AsyncWriteExt;
#[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 response = client
.get_object()
.bucket("mybucket")
.key("example.jpg")
.send()
.await?;
let mut file = File::create("downloaded_example.jpg").await?;
let bytes = response.body.collect().await?.into_bytes();
file.write_all(&bytes).await?;
println!("ダウンロード成功!");
Ok(())
}
{
"Name": "<string>",
"Prefix": "<string>",
"MaxKeys": 123,
"IsTruncated": true,
"Contents": [
{
"Key": "<string>",
"LastModified": "2023-11-07T05:31:56Z",
"ETag": "<string>",
"Size": 123,
"StorageClass": "<string>"
}
]
}取得したいオブジェクトに対してREAD権限があることを確認してください。
オブジェクトの取得
Nami Cloud Storageからオブジェクトを取得します。オブジェクトデータはレスポンスボディにストリーミングされます。ベースURL
https://${bucketname}.storage.nami.cloud
パラメータ
取得するオブジェクトのキー
ヘッダー
Range
オブジェクトの指定されたバイト範囲をダウンロードします
If-Match
指定されたエンティティタグ(ETag)が同じ場合のみオブジェクトを返します
If-Modified-Since
指定された時間以降に変更された場合のみオブジェクトを返します
リクエスト例
curl "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" \
--output 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'
)
s3_client.download_file(
Bucket='mybucket',
Key='example.jpg',
Filename='downloaded_example.jpg'
)
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
import { createWriteStream } from "fs";
const client = new S3Client({
endpoint: "https://storage.nami.cloud",
credentials: {
accessKeyId: "YOUR_ACCESS_KEY",
secretAccessKey: "YOUR_SECRET_KEY",
},
});
async function downloadFile() {
const command = new GetObjectCommand({
Bucket: "mybucket",
Key: "example.jpg",
});
try {
const response = await client.send(command);
const writeStream = createWriteStream('downloaded_example.jpg');
response.Body.pipe(writeStream);
} catch (err) {
console.error("エラー:", err);
}
}
downloadFile();
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.Create("downloaded_example.jpg")
if err != nil {
panic(err)
}
defer file.Close()
result, err := s3Client.GetObject(&s3.GetObjectInput{
Bucket: aws.String("mybucket"),
Key: aws.String("example.jpg"),
})
if err != nil {
panic(err)
}
defer result.Body.Close()
_, err = file.ReadFrom(result.Body)
if err != nil {
panic(err)
}
}
use aws_sdk_s3::{Client, Config};
use aws_config::credentials::StaticCredentialsProvider;
use aws_types::region::Region;
use tokio::fs::File;
use tokio::io::AsyncWriteExt;
#[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 response = client
.get_object()
.bucket("mybucket")
.key("example.jpg")
.send()
.await?;
let mut file = File::create("downloaded_example.jpg").await?;
let bytes = response.body.collect().await?.into_bytes();
file.write_all(&bytes).await?;
println!("ダウンロード成功!");
Ok(())
}
レスポンス例
HTTP/1.1 200 OK
x-amz-id-2: ef8yU9AS1ed4OpIszj7UDNEHGran
x-amz-request-id: 318BC8BC143432E5
Date: Wed, 28 Oct 2023 22:32:00 GMT
Last-Modified: Wed, 28 Oct 2023 19:27:20 GMT
ETag: "b9875f283e5571ae9ac762fba126cf8d"
Content-Length: 434234
Content-Type: image/jpeg
Server: Nami Cloud
[オブジェクトデータ]
承認
AWS Signature Version 4
クエリパラメータ
Limits the response to keys that begin with the specified prefix
Sets the maximum number of keys returned in the response
⌘I