Request

Response

    Task 2 – Upload Input File

    In this task, you will use the resource API to upload the necessary inputs file to the server. For this walkthrough, you will upload the Bifrost graph file and the input file plane.usd file, which contains the geometry you will create trees on.

    By the end of this task you will know how to use upload URLs to upload input files to the server.

    You will use the following operations for this task:

    OperationMethod + Endpoint
    Get upload URLs GET spaces/{spaceId}/resources/{resourceId}/upload-urls
    Complete upload POST spaces/{spaceId}/uploads:complete

    Step 1 - Get an upload URL for the bifrost graph file

    Use the Get upload URLs operation to retrieve an upload URL. You will store the bifrost graph under the graphfile key in your default scratch storage space.

    Request

    curl -v 'https://developer.api.autodesk.com/flow/storage/v1/spaces/scratch:@default/resources/graphfile/upload-urls' \
       -X 'GET' \
       -H 'Authorization: Bearer <ACCESS_TOKEN_FROM_TASK_1>'
    

    Response

    {
        "urls": [
            {
            "url": "https://com-autodesk-oss-direct-upload.s3.amazonaws.com/7a/26/0a/56/bucket/bifrost1-prd-scratch-space/signed-url-uploads/..."
            }
        ],
        "upload": {
            "expiresAt": "2024-06-20T00:00:00Z",
            "id": "AQICAHjdZwoyNEgA8bmp66wGy6Ir33...",
            "resourceId": "graphfile"
        }
    }
    
    Show More

    Step 2 - Upload the bifrost graph file

    Use the URL in the response from Step 1 to upload the Bifrost graph file.

    Request

    curl -X PUT -H --data-binary @<PATH_TO_ADD_TREES_GRAPH_FILE> "<SIGNED_UPLOAD_URL_FROM_STEP_1>"
    

    Step 3 - Complete the bifrost graph file upload

    Complete the upload by calling Complete upload. This tells the resource API that you are done uploading the file.

    • The etag value should come from the headers of the response in Step 2.
    • The uploadId value should come from the response in Step 1.

    Request

    curl -v 'https://developer.api.autodesk.com/flow/storage/v1/spaces/scratch:@default/uploads:complete' \
       -X 'POST' \
       -H 'Authorization: Bearer <ACCESS_TOKEN_FROM_TASK_1>' \
           -H 'Content-Type: application/json' \
           -d '{
                                "resourceId": "graphfile",
                                "uploadId": "AQICAHjdZwoyNEgA8bmp66wGy6Ir33...",
                                "parts": [
                                {
                                        "etag": "c0263e1..."
                                }
                          ]
                        }'
    
    Show More

    Response

    {
        "size": 99774,
        "urn": "urn:adsk:fc.scratch:us-west.prd:resource:@default/graphfile"
    }
    

    Step 4 - Get an upload URL for the input file plane.usd

    Like in Step 1, use Get upload URLs to retrieve an upload URL. Store the input file (plane.usd) under the inputfile key in your default scratch storage space.

    Request

    curl -v 'https://developer.api.autodesk.com/flow/storage/v1/spaces/scratch:@default/resources/inputfile/upload-urls' \
       -X 'GET' \
       -H 'Authorization: Bearer <ACCESS_TOKEN_FROM_TASK_1>'
    

    response

    {
        "urls": [
            {
            "url": "https://com-autodesk-oss-direct-upload.s3.amazonaws.com/7a/26/0a/56/bucket/bifrost1-prd-scratch-space/signed-url-uploads/..."
            }
        ],
        "upload": {
            "expiresAt": "2024-06-20T00:00:00Z",
            "id": "AQICAHjdZwoyNEgA8bmp66wGy6Ir33...",
            "resourceId": "inputfile"
        }
    }
    
    Show More

    Step 5 - Upload the input file plane.usd

    Like in Step 2, use the URL in the response from Step 4 to upload the input file, plane.usd.

    Request

    curl -X PUT -H --data-binary @<PATH_TO_PLANE_USD_FILE> "<SIGNED_UPLOAD_URL_FROM_STEP_4>"
    

    Step 6 - Complete the bifrost graph file

    Like in Step 3, complete the upload by calling Complete upload. This tells the resource API that you are done uploading the file.

    • The etag value should come from the headers of the response in Step 5.
    • The uploadId value should come from the response in Step 4.

    Request

    curl -v 'https://developer.api.autodesk.com/flow/storage/v1/spaces/scratch:@default/uploads:complete' \
       -X 'POST' \
       -H 'Authorization: Bearer <ACCESS_TOKEN_FROM_TASK_4>' \
           -H 'Content-Type: application/json' \
           -d '{
                                "resourceId": "inputfile",
                                "uploadId": "AQICAHjdZwoyNEgA8bmp66wGy6Ir33...",
                                "parts": [
                                        {
                                                "etag": "974f6c84b1e75903ad6b0f9da044f6e6"
                                        }
                                ]
                        }'
    
    Show More

    Response

    {
        "size": 1380310,
        "urn": "urn:adsk:fc.scratch:us-west.prd:resource:@default/inputfile"
    }