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:

C Example

#include <C_CkRest.h>
#include <C_CkStringBuilder.h>
#include <C_CkJsonObject.h>

void ChilkatSample(void)
    {
    HCkRest rest;
    BOOL success;
    BOOL bTls;
    int port;
    BOOL bAutoReconnect;
    HCkStringBuilder sbResponseBody;
    HCkJsonObject jsonResponse;
    const char *id;
    const char *object;
    int created;
    const char *filename;
    const char *purpose;
    int size;
    const char *type;
    const char *url;

    rest = CkRest_Create();

    //  URL: https://files.stripe.com/v1/files/file_1BnEEuGswQrCoh0XqB3XkqAg
    bTls = TRUE;
    port = 443;
    bAutoReconnect = TRUE;
    success = CkRest_Connect(rest,"files.stripe.com",port,bTls,bAutoReconnect);
    if (success != TRUE) {
        printf("ConnectFailReason: %d\n",CkRest_getConnectFailReason(rest));
        printf("%s\n",CkRest_lastErrorText(rest));
        CkRest_Dispose(rest);
        return;
    }

    CkRest_SetAuthBasic(rest,"STRIPE_SECRET_KEY","");

    sbResponseBody = CkStringBuilder_Create();
    success = CkRest_FullRequestNoBodySb(rest,"GET","/v1/files/file_1BnEEuGswQrCoh0XqB3XkqAg",sbResponseBody);
    if (success != TRUE) {
        printf("%s\n",CkRest_lastErrorText(rest));
        CkRest_Dispose(rest);
        CkStringBuilder_Dispose(sbResponseBody);
        return;
    }

    jsonResponse = CkJsonObject_Create();
    CkJsonObject_LoadSb(jsonResponse,sbResponseBody);

    id = CkJsonObject_stringOf(jsonResponse,"id");
    object = CkJsonObject_stringOf(jsonResponse,"object");
    created = CkJsonObject_IntOf(jsonResponse,"created");
    filename = CkJsonObject_stringOf(jsonResponse,"filename");
    purpose = CkJsonObject_stringOf(jsonResponse,"purpose");
    size = CkJsonObject_IntOf(jsonResponse,"size");
    type = CkJsonObject_stringOf(jsonResponse,"type");
    url = CkJsonObject_stringOf(jsonResponse,"url");


    CkRest_Dispose(rest);
    CkStringBuilder_Dispose(sbResponseBody);
    CkJsonObject_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"
}