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

Delphi ActiveX Example

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

begin
rest := TChilkatRest.Create(Self);

//  URL: https://files.stripe.com/v1/files/file_1BnEEuGswQrCoh0XqB3XkqAg
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/file_1BnEEuGswQrCoh0XqB3XkqAg',sbResponseBody.ControlInterface);
if (success <> 1) then
  begin
    Memo1.Lines.Add(rest.LastErrorText);
    Exit;
  end;

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

id := jsonResponse.StringOf('id');
object := jsonResponse.StringOf('object');
created := jsonResponse.IntOf('created');
filename := jsonResponse.StringOf('filename');
purpose := jsonResponse.StringOf('purpose');
size := jsonResponse.IntOf('size');
type := jsonResponse.StringOf('type');
url := jsonResponse.StringOf('url');

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