PowerBuilder 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:

PowerBuilder Example

integer li_rc
oleobject loo_Rest
integer li_Success
integer li_BTls
integer li_Port
integer li_BAutoReconnect
oleobject loo_SbResponseBody
oleobject loo_JsonResponse
string ls_Id
string ls_Object
integer li_Created
string ls_Filename
string ls_Purpose
integer li_Size
string ls_Type
string ls_Url

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")
if li_rc < 0 then
    destroy loo_Rest
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//  URL: https://files.stripe.com/v1/files/file_1BnEEuGswQrCoh0XqB3XkqAg
li_BTls = 1
li_Port = 443
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("files.stripe.com",li_Port,li_BTls,li_BAutoReconnect)
if li_Success <> 1 then
    Write-Debug "ConnectFailReason: " + string(loo_Rest.ConnectFailReason)
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    return
end if

loo_Rest.SetAuthBasic("STRIPE_SECRET_KEY","")

loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Rest.FullRequestNoBodySb("GET","/v1/files/file_1BnEEuGswQrCoh0XqB3XkqAg",loo_SbResponseBody)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_SbResponseBody
    return
end if

loo_JsonResponse = create oleobject
li_rc = loo_JsonResponse.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JsonResponse.LoadSb(loo_SbResponseBody)

ls_Id = loo_JsonResponse.StringOf("id")
ls_Object = loo_JsonResponse.StringOf("object")
li_Created = loo_JsonResponse.IntOf("created")
ls_Filename = loo_JsonResponse.StringOf("filename")
ls_Purpose = loo_JsonResponse.StringOf("purpose")
li_Size = loo_JsonResponse.IntOf("size")
ls_Type = loo_JsonResponse.StringOf("type")
ls_Url = loo_JsonResponse.StringOf("url")


destroy loo_Rest
destroy loo_SbResponseBody
destroy loo_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"
}