home > support > API > Method list > Upload tour file > Upload tour file
Generate a pre-signed Amazon S3 URL that can be used to upload a file.
Once you have the URL upload your file to it and then tell TourCMS to process the file.
Endpoint | /c/tours/files/upload/url |
Formats | XML |
Example | /c/tours/files/upload/url.xml?id=1&filetype=image&fileid=1 |
Verb | GET |
PHP examples use the PHP Client Library with the return type set to SimpleXML
object tour_upload_file_get_url(int $tour, int $channel, string $file_type, int $file_id)
// The channel ID this tour belongs to.
$channel = 3930;
// The id of the tour the image should be added to
$tour = 1;
// The uploaded file type, either 'image' or 'document'
$file_type = 'image';
// Slot
$file_id = 1;
// Call TourCMS API, obtaining a URL to upload to
$result = $tourcms->tour_upload_file_get_url($tour, $channel, $file_type, $file_id);
if ($result->error == "OK") {
print "UPLOAD URL IS " . $result->upload_url . " AND EXPIRES AT " . $result->valid_until;
} else {
print $result->error;
}
UPLOAD URL IS https://s3.example.com/foo AND EXPIRES AT 2022-10-01 15:45:05
Looking for sample code in a different language? TourCMS and community provided API libraries
Parameter | Notes |
---|---|
id | Tour ID you want to upload a new file (document or image). |
file_type | Either 'image' or 'document' |
file_id | For images, 1 to 10 depending on which image slot to upload to. For documents only 1 document can currently be uploaded, so this must be set to 1 |
XML Node | Notes |
---|---|
request | Confirmation of the request that you sent |
error | Any error message returned, if there is no error this will just contain the text OK |
upload_url | The URL to PUT your file to. |
valid_until | When the URL will be available until, ISO 8601 date format 2022-10-07T11:40:09+00:00. After this time you will need to generate a new URL to be able to upload. |
valid_until_timestamp | When the URL will be available until, Unix timestamp format. After this time you will need to generate a new URL to be able to upload. |
tour_id | Confirmation of the ID of the tour the you told us the image would be uploaded to |
channel_id | Confirmation of the primary Channel you are using to access the API |
file_type | Confirmation of the file type you gave us ('image' or 'document') |
file_id | Confirmation of the file id / slot you gave us (1-10 for images, 1 for documents) |
PUT your file to the upload_url provided.