Unicode C Stripe: Retrieve a File Upload

Back to Index

Retrieves the details of an existing file object. Supply the unique file upload ID from a file creation request, and Stripe will return the corresponding transfer information.

Documentation: https://stripe.com/docs/api/curl#retrieve_file_upload

CURL Command

curl https://files.stripe.com/v1/files/file_1BnEEuGswQrCoh0XqB3XkqAg \
   -u STRIPE_SECRET_KEY:

Unicode C Example

#include <C_CkRestW.h>
#include <C_CkStringBuilderW.h>
#include <C_CkJsonObjectW.h>

void ChilkatSample(void)
    {
    HCkRestW rest;
    BOOL success;
    BOOL bTls;
    int port;
    BOOL bAutoReconnect;
    HCkStringBuilderW sbResponseBody;
    HCkJsonObjectW jsonResponse;
    const wchar_t *id;
    const wchar_t *object;
    int created;
    const wchar_t *filename;
    const wchar_t *purpose;
    int size;
    const wchar_t *type;
    const wchar_t *url;

    rest = CkRestW_Create();

    //  URL: https://files.stripe.com/v1/files/file_1BnEEuGswQrCoh0XqB3XkqAg
    bTls = TRUE;
    port = 443;
    bAutoReconnect = TRUE;
    success = CkRestW_Connect(rest,L"files.stripe.com",port,bTls,bAutoReconnect);
    if (success != TRUE) {
        wprintf(L"ConnectFailReason: %d\n",CkRestW_getConnectFailReason(rest));
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        return;
    }

    CkRestW_SetAuthBasic(rest,L"STRIPE_SECRET_KEY",L"");

    sbResponseBody = CkStringBuilderW_Create();
    success = CkRestW_FullRequestNoBodySb(rest,L"GET",L"/v1/files/file_1BnEEuGswQrCoh0XqB3XkqAg",sbResponseBody);
    if (success != TRUE) {
        wprintf(L"%s\n",CkRestW_lastErrorText(rest));
        CkRestW_Dispose(rest);
        CkStringBuilderW_Dispose(sbResponseBody);
        return;
    }

    jsonResponse = CkJsonObjectW_Create();
    CkJsonObjectW_LoadSb(jsonResponse,sbResponseBody);

    id = CkJsonObjectW_stringOf(jsonResponse,L"id");
    object = CkJsonObjectW_stringOf(jsonResponse,L"object");
    created = CkJsonObjectW_IntOf(jsonResponse,L"created");
    filename = CkJsonObjectW_stringOf(jsonResponse,L"filename");
    purpose = CkJsonObjectW_stringOf(jsonResponse,L"purpose");
    size = CkJsonObjectW_IntOf(jsonResponse,L"size");
    type = CkJsonObjectW_stringOf(jsonResponse,L"type");
    url = CkJsonObjectW_stringOf(jsonResponse,L"url");


    CkRestW_Dispose(rest);
    CkStringBuilderW_Dispose(sbResponseBody);
    CkJsonObjectW_Dispose(jsonResponse);

    }

Sample JSON Response Body

{
  "id": "file_1BnEEuGswQrCoh0XqB3XkqAg",
  "object": "file_upload",
  "created": 1516661888,
  "filename": "path",
  "purpose": "sigma_scheduled_query",
  "size": 500,
  "type": "csv",
  "url": "https://stripe-upload-api.s3.amazonaws.com/uploads/file_1BnEEuGswQrCoh0XqB3XkqAg?AWSAccessKeyId=KEY_ID\u0026Expires=TIMESTAMP\u0026Signature=SIGNATURE"
}