Delphi ActiveX 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

Delphi ActiveX Example

var
rest: TChilkatRest;
success: Integer;
bTls: Integer;
port: Integer;
bAutoReconnect: Integer;
sbResponseBody: TChilkatStringBuilder;
jsonResponse: TChilkatJsonObject;
object: WideString;
url: WideString;
has_more: Integer;
i: Integer;
count_i: Integer;
id: WideString;
created: Integer;
filename: WideString;
purpose: WideString;
size: Integer;
type: WideString;

begin
rest := TChilkatRest.Create(Self);

//  URL: https://files.stripe.com/v1/files?limit=3
bTls := 1;
port := 443;
bAutoReconnect := 1;
success := rest.Connect('files.stripe.com',port,bTls,bAutoReconnect);
if (success <> 1) then
  begin
    Memo1.Lines.Add('ConnectFailReason: ' + IntToStr(rest.ConnectFailReason));
    Memo1.Lines.Add(rest.LastErrorText);
    Exit;
  end;

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

sbResponseBody := TChilkatStringBuilder.Create(Self);
success := rest.FullRequestNoBodySb('GET','/v1/files?limit=3',sbResponseBody.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(rest.LastErrorText);
    Exit;
  end;

jsonResponse := TChilkatJsonObject.Create(Self);
jsonResponse.LoadSb(sbResponseBody.ControlInterface);

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 do
  begin
    jsonResponse.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;
  end;

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"
    }
  ]
}