For AI agents: the complete documentation index is available at https://docs.dataplatform.ovh.net/ja/llms.txt, the full documentation bundle is available at https://docs.dataplatform.ovh.net/ja/llms-full.txt, and this page is available as Markdown at https://docs.dataplatform.ovh.net/ja/legacy/api-reference-datastore.md.
  • 🇯🇵 日本語
  • API リファレンス: バケット

    Warning

    このページでは、ForePaaS レガシープラットフォームについて説明しています。このプラットフォームは新規登録を受け付けていません。OVHcloud Data Platform を使用している場合は、Data Platform の APIを参照してください。

    ForePaaS バケットは、AWS S3 クライアントと完全に互換性があります。 これらとやり取りするには、ForePaaS Directory アカウントからAPI キーとシークレットキーを生成する必要があります。

    AWS CLI を使用する

    下記のコードスニペットのベース URL では、my-dataplantプロジェクトのサブドメインに置き換える必要があります。

    1. https://aws.amazon.com/cli/ から AWS CLI クライアントをインストールします。
    2. AWS CLI を構成します。名前付きプロファイルを使用することをお勧めします。
    $ aws configure --profile mydataplant
    AWS Access Key ID [None]: your_access_key
    AWS Secret Access Key [None]: your_secret_key
    Default region name [None]: forepaas
    Default output format [None]:
    1. MinIO サーバー用に AWS Signature Version 4 を有効にします。
    aws configure set s3.signature_version s3v4 --profile mydataplant
    1. 以下はコマンド例です ( my-dataplantプロジェクトのサブドメインに置き換えてください) :
    # list your buckets
    aws --profile mydataplant --endpoint-url https://my-dataplant.forepaas.io/datastore s3 ls
    
    # list contents inside bucket
    aws --profile mydataplant --endpoint-url https://my-dataplant.forepaas.io/datastore s3 ls s3://mybucket
    
    # make a bucket
    aws --profile mydataplant --endpoint-url https://my-dataplant.forepaas.io/datastore s3 mb s3://mybucket
    
    # add an object to a bucket
    aws --profile mydataplant --endpoint-url https://my-dataplant.forepaas.io/datastore s3 cp my-file.csv s3://mybucket
    
    # delete an object from a bucket
    aws --profile mydataplant --endpoint-url https://my-dataplant.forepaas.io/datastore s3 rm s3://mybucket/my-file.csv
    
    # remove a bucket
    aws --profile mydataplant --endpoint-url https://my-dataplant.forepaas.io/datastore s3 rb s3://mybucket
    

    名前付きプロファイル内のエントリポイント URL を管理するには、このドキュメントページを参照してください: プロファイルごとにエントリポイント URL を構成する


    Rclone を使用する

    下記のコードスニペットのベース URL では、my-dataplantプロジェクトのサブドメインに置き換える必要があります。

    1. https://rclone.org/downloads/ から rcloneをインストールします。
    2. rclone を構成します ( my-dataplantプロジェクトのサブドメインに置き換えてください) 。
    rclone config create my-dataplant s3 provider Minio region forepaas env_auth false
    rclone config update my-dataplant endpoint https://my-dataplant.forepaas.io/datastore
    rclone config update my-dataplant access_key_id YOUR_ACCESS_KEY
    rclone config update my-dataplant secret_access_key YOUR_SECRET_KEY
    1. 必要に応じて rclone の設定ファイルの場所を確認します。
    rclone config file
    1. 構成を確認します。
    rclone config show my-dataplant
    [my-dataplant]
    type = s3
    provider = Minio
    region = forepaas
    env_auth = false
    endpoint = https://my-datplant.forepaas.io/datastore
    access_key_id = YOUR_ACCESS_KEY
    secret_access_key = YOUR_SECRET_KEY
    1. 簡単なコマンド (詳細は rclone ドキュメントを参照してください) :
    # listing buckets
    rclone lsd my-dataplant:
    
    # create a bucket
    rclone mkdir my-dataplant:test-rclone
    
    # generate a local docs for test purpuse
    rclone gendocs docs
    
    # copy ./docs/ to test-rclone
    rclone copy docs my-dataplant:test-rclone/docs
    # what is the size of a bucket or a path ?
    rclone size my-dataplant:test-rclone
    Total objects: 69
    Total size: 239.570 kBytes (245320 Bytes)
    
    # displays a tree
    rclone tree my-dataplant:test-rclone
    # move files in bucket
    rclone move my-dataplant:test-rclone/docs/commands my-dataplant:test-rclone/commands
    
    # syncing source to destination
    rclone sync --dry-run docs my-dataplant:test-rclone/docs
    
    # listing files in a human redable way
    rclone lsl my-dataplant:test-rclone
    # listing files with format options
    rclone lsf  --format "tsp" --recursive my-dataplant:test-rclone
    
    # deleting files greater than 1k
    rclone --min-size 1k lsl my-dataplant:test-rclone/commands
    rclone --dry-run --min-size 1k delete my-dataplant:test-rclone/commands
    rclone --min-size 1k delete my-dataplant:test-rclone/commands
    # copy files in ./commands
    rclone copy my-dataplant:test-rclone/commands commands
    # delete an entire path
    rclone delete my-dataplant:test-rclone/commands/

    NodeJS を使用する

    下記のコードスニペットのベース URL では、[DATAPLANT_NAME]プロジェクトのサブドメインに置き換える必要があります。

    # Add aws-sdk to your application with the following command
    yarn add aws-sdk
    # Or
    npm i -s aws-sdk
    const AWS = require('aws-sdk')
    const fs = require('fs')
    
    // Modify those values for your environment
    let accessKey = '[ACCESS_KEY]'
    let secretKey = '[SECRET_KEY]'
    let endpoint = 'https://[DATAPLANT_NAME].eu.dataplatform.ovh.net'
    let bucket = '[BUCKET_NAME]'
    let region = 'forepaas'
    
    // Constructs a service object. This object has one method for each API operation.
    const dataStoreClient = new AWS.S3({
      accessKeyId: accessKey,
      secretAccessKey: secretKey,
      endpoint: `${endpoint}/datastore`,
      region: region,
      signatureVersion: 'v4',
      s3ForcePathStyle: true
    })
    
    
    ////////////////////////////////
    // Adds an object to a bucket //
    ////////////////////////////////
    let uploadStream = fs.createReadStream('./file.csv')
    dataStoreClient.putObject({
      Bucket: bucket,
      Key: 'file.csv',
      Body: uploadStream
    }, (err) => {
      if (err) console.error(err)
      else console.info('File uploaded')
    })
    
    
    /////////////////////////////////////
    // Retrieves objects from a bucket //
    /////////////////////////////////////
    let downloadStream = fs.createWriteStream('./file_downloaded.csv')
    dataStoreClient.getObject({
        Bucket: bucket,
        Key: 'file.csv'
      })
      .createReadStream()
      .on('error', (err) => {
        console.error(err)
      })
      .pipe(downloadStream)
      .on('close', () => {
        console.info('File downloaded')
      })
    
    
    /////////////////////////////////////
    // Returns some or all (up to 1000) of the objects in a bucket.
    /////////////////////////////////////
    dataStoreClient.listObjects({
      Bucket: bucket
    }, (err, data) => {
      if (data && data.Contents) {
        data.Contents.forEach(file => {
          console.info(`${file.Key} (${file.Size} bytes)`)
        })
      }
    })

    Python を使用する

    下記のコードスニペットのベース URL では、[DATAPLANT_NAME]プロジェクトのサブドメインに置き換える必要があります。

    # Install boto3 with the following command:
    pip install boto3
    import boto3
    from botocore.client import Config
    
    # Modify those values for your environment
    dataplant_url = 'https://[DATAPLANT_NAME].eu.dataplatform.ovh.net'
    access_key = '[ACCESS_KEY]'
    secret_key = '[SECRET_KEY]'
    bucket = '[BUCKET_NAME]'
    region = 'forepaas'
    
    # Constructs a service object. This object has one method for each API operation.
    datastore = boto3.client(
      's3',
      endpoint_url='{dataplant}/datastore'.format(dataplant=dataplant_url),
      aws_access_key_id=access_key,
      aws_secret_access_key=secret_key,
      config=Config(signature_version='s3v4'),
      region_name=region
    )
    
    # Adds an object to a bucket
    datastore.upload_file(
      Bucket=bucket,
      Filename='./file.csv',
      Key='file.csv')
    
    # Retrieves objects from a bucket
    datastore.download_file(
      Bucket=bucket,
      Filename='./file_downloaded.csv',
      Key='file.csv')
    
    # Returns some or all (up to 1000) of the objects in a bucket.
    # You can use the request parameters as selection criteria to return a subset of the objects in a bucket.
    if datastore.list_objects(Bucket=bucket):
      for file in datastore.list_objects(Bucket=bucket)['Contents']:
        print('{name} ({size} bytes)'.format(name=file['Key'], size=file['Size']))