Skip to content

Append Data To File

The Append operation allows adding new content to the end of an existing file. The operation writes new data to the file without overwriting the existing content.

Method

PUT/POST

Endpoint URL

The xxxx.backendless.app is a subdomain assigned to your application. For more information see the Client-side Setup section of this documentation.

Append Raw Text From The Request Body

PUT https://xxxx.backendless.app/api/files/append/<path>

where:

Argument                Description
<path> Path to the file that must be appended with new data.

Append Base64 Encoded Contents From The Request Body

The operation below takes the Base64 encoded data in the request body and appends the decoded content to the target file:

PUT https://xxxx.backendless.app/api/files/append/binary/<path>

where:

Argument                Description
<path> Path to the file that must be appended with the decoded data.

Append The Content Using A File Stored Locally

POST https://xxxx.backendless.app/api/files/append/<path>

where:

Argument                Description
<path> Path to the file that must be appended with the content from a file stored locally.

Request Headers

Append Raw Text From The Request Body

Content-Type: text/plain

Append Base64 Encoded Contents From The Request Body

Content-Type: text/plain

Append The Content Using A File Stored Locally

Content-Type: multipart/form-data

Request Body

For each route type, Backendless provides a separate request body that must be used when invoking any of the three operations:

Append raw text from the Request Body

The request body must contain the raw data, for instance: 'The quick brown fox jumps over the lazy dog'

Append Base64 Encoded content from the Request Body

The request body must contain the Base64 encoded data as raw text, for instance: 'VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw=='

Append content from a local file

The request body should include the form data that specifies the local file path to be used for the append operation. For instance: '=@"/C:/path/to/local/file.txt"'. For more information, refer to the official cURL documentation for the -F(--form) option.

Response Body

The URL containing the path to the file with the newly appended content. This URL can be used to download the file directly from Backendless.

Example

Append raw text from the Request Body

The example below appends the raw text 'The quick brown fox jumps over the lazy dog' to the testFile located in the customFolder. For clarification purposes, the customFolder is located in the root directory of Backendless.

curl --location --request PUT 'https://xxxx.backendless.com/api/files/append/customFolder/testFile' \  
--header 'Content-Type: text/plain' \  
--data-raw 'The quick brown fox jumps over the lazy dog'

Append Base64-encoded content from the Request Body

The example below sends the Base64 encoded data in the request body as the raw text, and upon the delivery to the Backendless the data is decoded to a string value and appended to the testFile located in the customFolder. For clarification purposes, the customFolder is located in the root directory of Backendless.

The following Base64 encoded data 'VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw==' represents the phrase 'The quick brown fox jumps over the lazy dog' when decoded.  

curl --location --request PUT 'https://xxxx.backendless.com/api/files/append/binary/customFolder/testFile' \  
--header 'Content-Type: text/plain' \  
--data-raw 'VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZw=='

Append content from a local file

In the example below, the content of the file located locally at "/C:/path/to/local/file.txt" (Windows platform) is appended to the "testFile" stored in Backendless. As you can see, we must provide the path to the file using the --form option in order to transfer the content stored locally. For clarification purposes, the customFolder is located in the root directory of Backendless.

curl --location --request POST 'https://xxxx.backendless.com/api/files/append/customFolder/testFile' \  
--header 'Content-Type: multipart/form-data' \  
--form '=@"/C:/path/to/local/file.txt"'

Codeless Reference

files_api_append_file_1

where:

Argument                Description
file path A path for a file stored in Backendless. The new content will be appended to this file. The path must start with a forward slash "/" identifying the root directory.
text / source URL / bytes When text is selected, this Codeless block is instructed to append a string value to the specified file stored in Backendless.

Thesource URL option identifies location of a remote file to append the content of. When this option is selected, the Codeless block uses the content of the remote file and appends it to the file stored in Backendless.

The bytes option identifies the binary data. By selecting this option, you instruct the Codeless block to expect bytes that will be decoded and appended to the file stored in Backendless.
return URL of the file When this checkbox is selected, the operation will return the URL to the file where the new data was appended.

Returns a URL containing the path to the file with the newly appended content. This URL can be used to download the file directly from Backendless.

Consider a text file stored in Backendless:

files_api_append_file_2

This file has the following content:

files_api_append_file_3

Appending text to file

The example below appends the "5. lettuce" text to the file. Note that the file is stored in the "/notes/grocery" folder.

files_api_append_file_4

The operation has successfully appended the new text to the file:

files_api_append_file_5

Appending bytes to file

The example below converts the string value " 5. Carrots" from text to bytes and appends it to the "dinner.txt" file stored in the "/notes/grocery/" directory. Note that you must use the "Convert data" Codeless block in order to convert text to bytes.

files_api_append_file_6

The result of this operation is shown below:

files_api_append_file_7

Append content from a remote file

The example below uses the contents of the remote file and appends it to the "dinner.txt" file stored in the "/notes/grocery" folder.

files_api_append_file_8

The result of this operation is shown below, as you can see a new string ( " 5. Strawberry" ) value was appended to the end of the file:

files_api_append_file_9