Uploads a file to Stripe.
curl https://files.stripe.com/v1/files \
-u STRIPE_SECRET_KEY: \
-F purpose=dispute_evidence \
-F file="@/path/to/a/file.jpg"
Dim rest As New ChilkatRest
Dim success As Long
' URL: https://files.stripe.com/v1/files
Dim bTls As Long
bTls = 1
Dim port As Long
port = 443
Dim bAutoReconnect As Long
bAutoReconnect = 1
success = rest.Connect("files.stripe.com",port,bTls,bAutoReconnect)
If (success <> 1) Then
Debug.Print "ConnectFailReason: " & rest.ConnectFailReason
Debug.Print rest.LastErrorText
Exit Sub
End If
success = rest.SetAuthBasic("STRIPE_SECRET_KEY","")
rest.PartSelector = "1"
success = rest.AddHeader("Content-Disposition","form-data; name=""purpose""")
success = rest.SetMultipartBodyString("dispute_evidence")
rest.PartSelector = "2"
Dim fileStream2 As New ChilkatStream
fileStream2.SourceFile = "/path/to/a/file.jpg"
success = rest.AddHeader("Content-Disposition","form-data; name=""/path/to/a/file.jpg""; filename=""/path/to/a/file.jpg""")
success = rest.AddHeader("Content-Type","image/jpeg")
success = rest.SetMultipartBodyStream(fileStream2)
rest.PartSelector = "0"
success = rest.AddHeader("Expect","100-continue")
Dim strResponseBody As String
strResponseBody = rest.FullRequestMultipart("POST","/v1/files")
If (rest.LastMethodSuccess <> 1) Then
Debug.Print rest.LastErrorText
Exit Sub
End If
Dim jsonResponse As New ChilkatJsonObject
success = jsonResponse.Load(strResponseBody)
Dim id As String
Dim object As String
Dim created As Long
Dim filename As String
Dim purpose As String
Dim size As Long
Dim type As String
Dim url As String
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")
{
"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"
}