Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Added sub-codes for 404 responses
Excerpt

Update a media file to in the dialogportal™ Media Archive.

The Media Archive provides a public repository for media files. Currently the allowed file type are:

File typecontentType
Imageimage/gif, image/jpeg etc.
Videoapplication/octet-stream
PDFapplication/pdf
Javascripttext/javascript, application/x-javascript or text/plain with .js fileName
Stylesheettext/css or text/plain with .css fileName
Fontapplication/x-font-ttf, application/x-font-woff, application/vnd.ms-fontobject
Iconimage/x-icon, image/vnd.microsoft.icon
HTCtext/x-component or text/plain with .htc fileName

Media in the archive is contained in a folder structure, and file and folder names are unique within their respective folders.

When attempting to create a media file with a name that already exists in the folder, the autoName field is used to determine the correct action. When autoName is omitted or set to false, a 303 response will be returned including a location header containing the URL to the existing media file. When autoName is true, the file will be created with an auto-incremented "index" appended to the file name, "file_1.txt", "file_2.txt" etc.

To add new folders simply include them in your folderPath. Folders that do not already exist will be createdMedia file content and description properties are updateable. The fileName and folderPath are used to uniquely identify the media file.

The fileName and folderPath have been sanitized, making them safe to use in a URL.

Endpoint ID:

91009101

Method:

Image Removed

Status
colourGreen
titlePUT

URL:

/content/media

Request body:

JSON data with information about the media to be createdupdated.

A file name or title for the media itemA to
Required fields:
 

contentfileName

The content, formatted as a base64 encoded text stringmedia file name.

 contentTypeThe content mime-type, i.e. "image/gif" or "text/plain".  

fileName

The contentType should be same as existing file.
Optional fields:
 folderPathThe folder path of the media file to be updated. This path is not the entire URL (which also contains the customer name, fileName etc.) but simply a "/"-delimited string of folder names. Exclude the folderPath to update a file in the root folder.
Optional updatable fields:
 content

The content, formatted as a base64 encoded text string.

 description

A description that will be displayed in dialogportal™

 autoName

A boolean value indicating that fileName should be renamed if a media file already exists with the same name. fileName will be renamed with a trailing "_{index}" (before the file extension, if it exists). The index will be the next valid index, starting from "_1", so multiple files named "file.txt" will be created as "file.txt", "file_1.txt", "file_2.txt" etc.

The default value is false.

Code Block
titleExample: Create Update a single pixel image
 {
   "contentfileName": "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==clear_1x1.gif",
   "contentTypefolderPath": "image/gifassets/generic_images/small",
   "fileNamecontent": "clear 1x1.gifR0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==",
   "folderPathdescription" : "Assets/Generic Images/Small",
   "autoName" : true
}

Response body:

A JSON object containing the url to the newly created content.
Code Block
titleExample
{
  "url": "https://media.dialogportal.com/customer_name/assets/generic_images/small/clear_1x1.This is a media description.",
   "contentType": "image/gif"
}

The URL format is:

Base URLhttps://media.dialogportal.com/
Customer name
customer_name/
Folder path
assets/generic_images/small/
File nameclear_1x1.gif
Note

Response body:

None

Status codes:

201204

Media created successfully.

 303

A media file with this name already exists in the folder.

The response includes a location header containing the URL to the existing media file.

updated successfully

 400.1Content type not recognized
 400.2Media files may not be larger than 2MB
 400.3Content type mismatch
 404.4Media file not found
 404.5Folder not found