API - Send source content
The purpose of this method is to send original content (or files) to translate to the project input directory. The method sends one file.
This method is equivalent to copying a file to the project's "IN" directory.
URL
(PUT) /api/files/file?token=&locale=&folder=&filename=
Please note that this is an HTTP PUT and not a GET action. The binary data of the file must be included in the message body.
Please note that multi-part attachments are not supported.
PARAMETERS
Parameters are:
token | The session token obtained when connecting. |
locale | The source language. This must correspond to the project source language code. Language codes are ISO 2 letter codes such as “en”, “fr”, “en-GB”, “en-US”, etc. |
filename | The relative path of the file including sub-directories.
Note the use of backslash separators as it is common on Windows systems. The file will be saved to the project input directory with the specified sub-directories. Sub-directories are created if these do not yet exist. Using sub-directories is useful if you want to organize files into folders. |
folder | Optional. Folder name |
MESSAGE BODY | Add the binary content of the file to the message body. Set content type to "Stream", such as in: Content-Type: Stream Do not use multi-part MIME contents as this is not supported by the Beebox. |
The file will be saved to the project input directory and then picked up from there by the Beebox. Always make sure to verify the HTTP status to make sure that your operation succeeded.
Example: If you specify the filename “folder1\myfile.xml”, the file will be saved to “c:\beebox\{project id}\in\folder1\myfile.xml”.
RESULTS
The method returns no result. An HTTP status of 204 indicates success.
Other HTTP status values indicate an error.
CONTENT ENCODING AND CODE PAGES
The actual content you include with your API call can be of any encoding (code page).
You can, but do not need, to "normalize" original text content to UTF-8 or similar. The Beebox, if properly configured, is capable of reading any code pages.
If you actually generate text content on the fly in PHP, Java etc. it is best practice to encode in UTF-8 for maximum language support.
If you send files from disk, it is best to send as binary content. Binary formats such as Microsoft Word or Adobe InDesign are sent unchanged obviously.
EXAMPLE
You send the Japanese file "pages\page1.html":
/api/files/file?token=...&filename=pages\page1.html&locale=ja
MESSAGE BODY:
The original Japanese html code (UTF-8 or other code page)
c:\Beebox\{project key}
\in
\pages\page1.html
The c:\Beebox root directory may be different in your setup.
USING POSTMAN
The following screenshots give an idea how to use the Google Chrome plugin "Postman" to submit a file. We suppose that you already have obtained a connection token.
First, choose the "PUT" method, insert the URL with the different parameters.
Second, click the "Headers" panel and set the Content-Type to Stream (first letter capitalized):