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/sdk/api-download-file-datastore.md.
  • 🇯🇵 日本語
  • バケットからファイルを公開する

    Warning

    再作業が保留中で、納期は未定です。 Front App SDK (ReactJS) と Front API SDK (NodeJS) の両方が置き換えられます。このページは現在のリリースを文書化し、正確であり、置き換えが出荷されるまで維持されます。これに対して書かれたコードは引き続き動作します。

    Lakehouse Manager バケット(オブジェクトストア)からファイルを提供するために、API にカスタムエンドポイントを追加できます。

    認証情報を取得する

    この新しい API エンドポイントを通じてファイルにアクセスするために認証する人/サービスは、Lakehouse Manager のバケットに対して少なくとも 読み取りアクセス を持っている必要があります。

    Datastore バケット読み取り の権限を含むロールを持つ Identity Access Manager ユーザー(またはサービスアカウント)を作成します。その後、このユーザーの API キーとシークレットキーを生成します。これらのキーは、API エンドポイントを設定する際に使用されます。


    ファイルを公開するためのカスタムモジュールを作成する

    API にこのコードを追加/編集できます。

    // forepaas.json
    // In modules key, add the configuration of your new module
      "s3-sample": {
        "version": "local",
        "dependencies": {
          "authentication": {
            "module": "iam"
          }
        }
      },

    フォルダ forepaas に、s3-sample という名前のサブフォルダを作成します。 その中で、2つの主要なファイルを作成する必要があります。

    // forepaas/s3-sample/forepaas.json
    {
      "id": "s3-sample",
      "type": "package",
      "name": "S3 Saple",
      "version": "1.0.0",
      "npmDependencies": {
        "aws-sdk": "2.966.0"
      }
    }
    // forepaas/s3-sample/factory.js
    const express = require('express')
    const router = express.Router()
    const AWS = require('aws-sdk')
    const util = require('util')
    
    
    // Modify those values for your environment
    let accessKey = 'YOUR_ACCESS_KEY'
    let secretKey = 'YOUR_SECRET_KEY'
    let endpoint = 'https://YOUR_PROJECT_SUBDOMAIN.eu.dataplatform.ovh.net'
    let bucket = 'project-YOUR_PROJECTID-YOUR_BUCKET'
    let region = 'forepaas'
    
    
    // If no authentication is bind, it will use that default function
    let defaultDependencies = {
      authentication: {
        checkSession:(req,cb) => cb()
      }
    }
      
    let dependencies = {}
    let factory = new AbstractFactory(dependencies)
    
    let createSuper = factory.create
    factory.create = function(moduleName) {
      createSuper.call(moduleName)
      this.moduleName = 's3-sample'
      factory.setDependencies(defaultDependencies)
      let dependencies = this.getDependencies()
    
      // Use authentication if binded in forepaas.json
      router.use(async (req,res,next)=>{
        try {
          req.session = await util.promisify(dependencies.authentication.checkSession)(req)
          next()
        } catch (err) {
          next(err)
        }
      })
    
      // Set our custom endpoint
      // Will be available on GET /s3-sample/custom-endpoint
      router.get('/custom-endpoint',async (req,res,next)=>{
        try {
          // Use s3 connector, to get a file in datstore
          const dataStoreClient = new AWS.S3({
            accessKeyId: accessKey,
            secretAccessKey: secretKey,
            endpoint: `${endpoint}/datastore`,
            region: region,
            signatureVersion: 'v4',
            s3ForcePathStyle: true
          })
    
          dataStoreClient.getObject({
            Bucket: bucket,
            Key: 'my-file.csv'
          })
          .createReadStream()
          .on('error', (err) => {
            next(err)
          })
          .pipe(res)
        } catch (err) {
          next(err)
        }
      })
    
      // Initialise the router for enable endpoint
      this.initRouter(router)
      return this
    }
    
    module.exports = factory

    API を起動する

    API をローカルまたは Data Platform 上で実行できます。

    エンドポイントを次のように取得します。

    GET API_URL/s3-sample/custom-endpoint

    認証を有効にしている場合(メインの forepaas.json ファイルから)、Identity Access Manager からの有効なトークンを持つクエリ文字列パラメータを追加する必要があります。

    GET API_URL/s3-sample/custom-endpoint?token=1234

    さらに詳しく

    当社のソリューションを実装するためのトレーニングや技術サポートが必要な場合は、営業担当者にお問い合わせください、またはこのリンクをクリックして、当社の Professional Services 専門家にカスタム分析を依頼し、見積もりを取得してください。

    Data Platform を構築するチームと直接やり取りし、質問をしたり、フィードバックを送信したり、Discord の専用 チャネル で交流したりできます。

    OVHcloud サービスについてサポートが必要な場合は、ヘルプセンター でリクエストを作成してください。

    ユーザーコミュニティ に参加してください。