Operations (sample payloads)
Main operationsCopy
Convert file from Base64Copy
Creates a new file from a Base64 encoded file.
Sample Input
1{2"file": {3"name": "example.txt",4"mime_type": "text/plain",5"data": "SGVsbG8gV29ybGQh"6},7"filename": "converted_example.txt"8}
Sample Output
1{2"file": {3"name": "converted_example.txt",4"url": "https://example.com/files/converted_example.txt",5"mime_type": "text/plain",6"expires": 16234567897}8}
Convert file to Base64Copy
Creates a new Base64 encoded file from an original file.
Sample Input
1{2"file": {3"name": "example.pdf",4"url": "https://example.com/files/example.pdf",5"mime_type": "application/pdf",6"expires": 16234567897},8"filename": "converted_example.txt"9}
Sample Output
1{2"file": {3"name": "converted_example.txt",4"url": "data:application/pdf;base64,JVBERi0xLjMNCiXi48/TDQoNCjEgMCBvYmoNCjw8DQovVHlwZSAvQ2F0YWxvZw0KL091dGxpbmVzIDIgMCBSDQovUGFnZXMgMyAwIFINCj4+DQplbmRvYmoNCg...",5"mime_type": "text/plain",6"expires": 16234567897}8}
Convert to UTF-8 from URLCopy
Creates a new file encoded into UTF-8 encoding, from an original file, using an URL.
Sample Input
1{2"original_encoding": "ISO-8859-1",3"url": "https://example.com/sample-file.txt",4"name": "converted-file.txt",5"headers": {6"User-Agent": "Tray.io Connector"7},8"authentication": {9"basic": {10"username": "user123",11"password": "pass456"12}13},14"status_code": {15"range": {16"start": 200,17"end": 29918}19}20}
Sample Output
1{2"file": {3"name": "converted-file.txt",4"url": "https://tray-files.s3.amazonaws.com/converted-file-123456.txt",5"mime_type": "text/plain",6"expires": 16234567897}8}
Create byte ranges listCopy
Create a list of byte range arrays for use with chunked uploads.
Sample Input
1{2"file": {3"name": "example.pdf",4"size": 1048576,5"type": "application/pdf"6},7"chunk_size": 2621448}
Sample Output
1{2"byteRanges": [3{4"startByte": 0,5"endByte": 2621436},7{8"startByte": 262144,9"endByte": 52428710},11{12"startByte": 524288,13"endByte": 78643114},15{16"startByte": 786432,17"endByte": 104857518}19],20"fileSize": 104857621}
Create file from contentCopy
Create a file from some content.
Sample Input
1{2"name": "customer_data.json",3"content": {4"id": 12345,5"name": "John Doe",6"email": "johndoe@example.com",7"age": 30,8"active": true9},10"base64_to_binary": false11}
Sample Output
1{2"file": {3"name": "customer_data.json",4"url": "https://example.com/files/customer_data.json",5"mime_type": "application/json",6"expires": 16725312007}8}
Create file from URLCopy
Create a file by downloading from a given URL.
Sample Input
1{2"url": "https://example.com/sample-file.pdf",3"name": "important-document.pdf",4"headers": {5"User-Agent": "Tray.io File Downloader"6},7"authentication": {8"basic": {9"username": "user123",10"password": "pass456"11}12},13"status_code": {14"range": {15"start": 200,16"end": 29917}18}19}
Sample Output
1{2"file": {3"name": "important-document.pdf",4"url": "https://files.tray.io/12345/important-document.pdf",5"mime_type": "application/pdf",6"expires": 16234567897},8"status_code": 200,9"headers": {10"Content-Type": "application/pdf",11"Content-Length": "2048000",12"Last-Modified": "Wed, 21 Oct 2023 07:28:00 GMT"13}14}
Get file sizeCopy
Gets the size of a file in bytes.
Sample Input
1{2"file": {3"name": "example.txt",4"content": "VGhpcyBpcyBhIHNhbXBsZSBmaWxlIGNvbnRlbnQ=",5"contentType": "text/plain",6"size": 287}8}
Sample Output
1{2"size": 283}
Read file contentsCopy
Reads a file's contents and outputs it as a string.
Sample Input
1{2"url": "https://example.com/files/sample.txt",3"name": "sample.txt",4"headers": {5"Accept": "text/plain"6},7"authentication": {8"basic": {9"username": "user123",10"password": "pass456"11}12},13"status_code": {14"range": {15"start": 200,16"end": 29917}18}19}
Sample Output
1{2"result": "This is the content of the sample.txt file.\nIt can contain multiple lines of text.\nThe file contents are returned as a string."3}
Read file contents as arrayCopy
Read a file's contents and output it as an array.
Sample Input
1{2"url": "https://example.com/sample.txt",3"delimiter": ",",4"use_regular_expressions": false,5"name": "sample.txt",6"headers": {7"Accept": "text/plain"8},9"authentication": {10"basic": {11"username": "user123",12"password": "pass456"13}14},15"status_code": {16"range": {17"start": 200,18"end": 29919}20},21"limit": 5,22"offset": 023}
Sample Output
1{2"result": [3"apple",4"banana",5"cherry",6"date",7"elderberry"8]9}
Upload file as form dataCopy
Upload a file to a URL as part of a 'FormData' object.
Sample Input
1{2"url": "https://api.example.com/upload",3"method": "post",4"form_data_properties": [5{6"file": {7"name": "document.pdf",8"content": "base64encodedcontent..."9},10"file_key": "uploaded_file"11},12{13"key": "description",14"value": "Important document"15},16{17"key": "user_id",18"value": "12345"19}20],21"headers": {22"Authorization": "Bearer token123"23},24"send_content_length_header": true25}
Sample Output
1{2"success": true,3"body": {4"message": "File uploaded successfully",5"file_id": "abc123"6},7"headers": {8"Content-Type": "application/json",9"Server": "nginx/1.18.0"10},11"status_code": 20012}
Upload file chunkCopy
Upload a chunk of a file. See documentation for an example use case.
Sample Input
1{2"file": {3"name": "example.txt",4"content": "VGhpcyBpcyBhIHNhbXBsZSBmaWxlIGNvbnRlbnQ=",5"content_type": "text/plain"6},7"url": "https://api.example.com/upload",8"method": "put",9"start_byte": 0,10"end_byte": 1023,11"headers": {12"Authorization": "Bearer token123",13"Content-Type": "application/octet-stream"14}15}
Sample Output
1{2"success": true,3"body": {4"message": "Chunk uploaded successfully",5"bytes_received": 10246},7"headers": {8"Content-Type": "application/json",9"Server": "nginx/1.18.0"10},11"status_code": 20012}
Upload file to URLCopy
Upload a file to a URL.
Sample Input
1{2"file": {3"name": "example.pdf",4"size": 1024000,5"mime_type": "application/pdf"6},7"url": "https://api.example.com/upload",8"method": "post",9"headers": {10"Authorization": "Bearer token123",11"X-Custom-Header": "CustomValue"12},13"return_response_as_file": true,14"return_response_file_name": "upload_result.json"15}
Sample Output
1{2"body": {3"message": "File uploaded successfully",4"file_id": "12345abcde"5},6"headers": {7"Content-Type": "application/json",8"Server": "nginx/1.18.0",9"Date": "Mon, 15 May 2023 10:30:45 GMT"10},11"status_code": 200,12"success": true13}