C++ Stripe: List all File Uploads

Back to Index

Returns a list of the files that you have uploaded to Stripe. The file uploads are returned sorted by creation date, with the most recently created file uploads appearing first.

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

CURL Command

curl https://files.stripe.com/v1/files?limit=3 \
   -u STRIPE_SECRET_KEY: \
   -G

C++ Example

#include <CkRest.h>
#include <CkStringBuilder.h>
#include <CkJsonObject.h>

void ChilkatSample(void)
    {
    CkRest rest;
    bool success;

    //  URL: https://files.stripe.com/v1/files?limit=3
    bool bTls = true;
    int port = 443;
    bool bAutoReconnect = true;
    success = rest.Connect("files.stripe.com",port,bTls,bAutoReconnect);
    if (success != true) {
        std::cout << "ConnectFailReason: " << rest.get_ConnectFailReason() << "\r\n";
        std::cout << rest.lastErrorText() << "\r\n";
        return;
    }

    rest.SetAuthBasic("STRIPE_SECRET_KEY","");

    CkStringBuilder sbResponseBody;
    success = rest.FullRequestNoBodySb("GET","/v1/files?limit=3",sbResponseBody);
    if (success != true) {
        std::cout << rest.lastErrorText() << "\r\n";
        return;
    }

    CkJsonObject jsonResponse;
    jsonResponse.LoadSb(sbResponseBody);

    const char *object = 0;
    const char *url = 0;
    bool has_more;
    int i;
    int count_i;
    const char *id = 0;
    int created;
    const char *filename = 0;
    const char *purpose = 0;
    int size;
    const char *type = 0;

    object = jsonResponse.stringOf("object");
    url = jsonResponse.stringOf("url");
    has_more = jsonResponse.BoolOf("has_more");
    i = 0;
    count_i = jsonResponse.SizeOfArray("data");
    while (i < count_i) {
        jsonResponse.put_I(i);
        id = jsonResponse.stringOf("data[i].id");
        object = jsonResponse.stringOf("data[i].object");
        created = jsonResponse.IntOf("data[i].created");
        filename = jsonResponse.stringOf("data[i].filename");
        purpose = jsonResponse.stringOf("data[i].purpose");
        size = jsonResponse.IntOf("data[i].size");
        type = jsonResponse.stringOf("data[i].type");
        url = jsonResponse.stringOf("data[i].url");
        i = i + 1;
    }
    }

Sample JSON Response Body

{
  "object": "list",
  "url": "/v1/files",
  "has_more": false,
  "data": [
    {
      "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"
    }
  ]
}