Box Developerドキュメント
 

    目的のレプリゼンテーションのリクエスト

    ガイド レプリゼンテーション 目的のレプリゼンテーションのリクエスト

    目的のレプリゼンテーションのリクエスト

    特定のレプリゼンテーションを選択するには、必要なレプリゼンテーション形式を定義するx-rep-hintsヘッダーを使用してGET /files/:idエンドポイントを呼び出します。

    curl https://api.box.com/2.0/files/123?fields=representations \
        -H "x-rep-hints: [pdf]" \
        -H "authorization: Bearer ACCESS_TOKEN"
    
    

    複数のサイズ

    形式によっては、特定のサイズを選択するために、dimensionsを渡すことが必要になる場合があります。そのためには、ヘッダーにdimensionsを追加します。

    curl https://api.box.com/2.0/files/123?fields=representations \
        -H "x-rep-hints: [jpg?dimensions=94x94]" \
        -H "authorization: Bearer ACCESS_TOKEN"
    
    

    複数のレプリゼンテーション

    x-rep-hintsヘッダーでさまざまなタイプを続けて指定することで、複数のレプリゼンテーションを取得できます。

    curl https://api.box.com/2.0/files/123?fields=representations \
        -H "x-rep-hints: [pdf][jpg?dimensions=94x94]" \
        -H "authorization: Bearer ACCESS_TOKEN"
    
    

    APIレスポンス

    このAPIコールの結果、{+asset_path}値を含むurl_template値を使用して1つ以上のレプリゼンテーションが返されます。

    {
      "etag": "1",
      "id": "123",
      "representations": {
        "entries": [
          {
            "content": {
              "url_template": "https://dl.boxcloud.com/api/2.0/internal_files/123/versions/345/representations/pdf/content/{+asset_path}"
            },
            "info": {
              "url": "https://api.box.com/2.0/internal_files/123/versions/345/representations/pdf"
            },
            "properties": {},
            "representation": "pdf",
            "status": {
              "state": "success"
            }
          }
        ]
      },
      "type": "file"
    }
    
    

    このレスポンスのurl_templateは、不明瞭なURLです。このURL形式は、時間が経つと変わる可能性があるため、{+asset_path}変数の有無を除き、この形式についてさまざまな憶測を立てないようにしてください。