Skip to end of metadata
Go to start of metadata

 

Replace a File

This method is used to replace previously uploaded files and returns the new URL for use in CME. The file schema field type for content requires a URL, so you must use this endpoint before saving/updating file content.

NOTE: Only use this endpoint if you want to replace a file. If you're just uploading a file, use Upload a File.

NOTE: This method uses the S3 settings in the org to delete previous files. If those S3 settings ever change, then all files previously uploaded will become zombie files. This method will simply ignore any URLs you pass it that you do not have access to delete (due to changed S3 settings) or are simply invalid.

NOTE: This request must be a multipart/form-data for the file to be uploaded. Please search for how to complete a multipart/form-data request in your framework/programming language.

 

Method

PUT

 

 

Headers

In order to provide CME with the JWT, you must provide a header named Authorization and the token must be prefixed with the word Bearer.

Key

Authorization

Value

Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MTY3NCwiZW1haWwiOiJvcmdvd25lckBjeWJhZ2UuY29tIiwiZmlyc3RfbmFtZSI6IkN5YmFnZSIsImxhc3RfbmFtZSI6Ik9yZyBPd25lciIsIm9yZ3MiOltdLCJzZXNzaW9uX2lkIjoiNzk3ZWRjNmY2Mjk5Y2JmYmEyODE3NDlhMGFlZjI0YmNhNmZmODM0NSIsIm9yZ19pZCI6NTEsIm9yZ19uYW1lIjoiQ3liYWdlIENsZWFuIiwiaWF0IjoxNDg4MjI5ODY0LCJleHAiOjE0ODgzMTYyNjR9.Vd7BCYEkeWOq2B3_3Np9ylYDwYaAWyE1-e4ZvCIvK4E

 

Request Parameters

Required parameters are underlined.

Parameter

Value

Description

file

File

The file being uploaded.

previousFile

URL

A string URL to a file previously uploaded through the upload endpoint.

 

Request

Content-Type: multipart/form-data

Include the two fields above: file and previousFile.

 

Response

A successful response will have a 200 status code and a body containing the URL of the new file.

{
"message": "Successfully uploaded file to S3.",
"file": "https://lbs-dev.s3.amazonaws.com/cyb-cln/e4d22a023db54fa08680b11078e0d9d6/dog_typing_fast.gif"
}

 

 

Error Handling

An error response will return a 400 (or 500 for internal server error) and a message:

{
"message": "No file found in the request."
}

 

  • No labels