Secured Content Storage Service

File storage management, upload and retrieval service.

This service is natively used by:

In IoT-connector, content service files are also available for device to be securly downloaded.

Operations


Configuration parameters

Name Type Description
retention_policy [ object ] Retention policy to delete files
retention_policy[].ttl ^[0-9]+[dy]$ Time to live, should be days or years, eg: 1d, 30d
retention_policy[].name string The name of this policy
retention_policy[].prefix string The prefix to match, if empty, the policy will apply to all

Operations

clear

Deletes all the content for the given context/solution

Responses

An array of the ids of the deleted content items

Content: [ object ]

Name Type Description
id string The id of the content item
An error occurred

Content: object Error information

Name Type Description
type string The error message's type
message string The associated error message

Example

response.message = Content.clear()

delete

Delete the given content item

Arguments

parameters - object - Object containing service call parameters.
Name Type Description
id string The content unique ID

Responses

The content item was deleted

Content: object The content item id

Name Type Description
id string The id of the content item
An error occurred

Content: object Error information

Name Type Description
type string The error message's type
message string The associated error message

Example

response.message = Content.delete({
  id = 'image.png',
})

deleteMulti

Delete multiple files in a solution

Arguments

parameters - object - Object containing service call parameters.
Name Type Description
body [ string ] The list of files user wants to delete

Responses

Files deleted

Content: nil

Example

return Content.deleteMulti({"file1", "file2"})

download

Get the download URL for the specified content item

Arguments

parameters - object - Object containing service call parameters.
Name Type Description
id string The content unique ID
expires_in ^[0-9]+$ Time duration in seconds or URL validity

Responses

The download URL

Content: object HTTP information for client-side content downloads

Name Type Description
id string The id of the content item
url string The URL to use
method "GET" The HTTP method to use with this URL
An error occurred

Content: object Error information

Name Type Description
type string The error message's type
message string The associated error message

Example

local filename = "image.png" local file_type = "image/png" local expires_in = 600
local presigned_download = Content.download({
  id = filename,
  type = file_type,
  expires_in = expires_in,
})
-- Create curl download command local curl_command = "curl --output " .. filename .. " "
curl_command = curl_command .. presigned_download.url
return curl_command

downloadAll

Get the download URL list for this context

Arguments

parameters - object - Object containing service call parameters.
Name Type Description
limit integer {..1000} Number of files to query
cursor string Indicate the cursor when query files, normally returned by request
expires_in ^[0-9]+$ Time duration in seconds or URL validity

Responses

The download URL list

Content: [ object ]

Name Type Description
id string The id of the content item
url string The URL to use
method "GET" The HTTP method to use with this URL
An error occurred

Content: object Error information

Name Type Description
type string The error message's type
message string The associated error message

Example

local opts = {
  cursor = nil, -- specify the file id to start with
  limit = 5,
  expires_in = 600
}
-- This will return download urls for all files return Content.downloadAll(opts)

info

Retrieve metadata and tags associated with uploaded content

Arguments

parameters - object - Object containing service call parameters.
Name Type Description
id string The content unique ID

Responses

The content info

Content: object A content item's metadata and tags

Name Type Description
id string The id of the content item
tags object Tags and their values for the content item
tags.* string Tag value
type string The mime type of the content item
length integer The content item's length in bytes
last_modified string(dateTime) Last modified timestamp (formatted as ISO 8601)
An error occurred

Content: object Error information

Name Type Description
type string The error message's type
message string The associated error message

Example

response.message = Content.info({
  id = 'image.png',
})

list

Get the list of content items for the solution

Arguments

parameters - object - Object containing service call parameters.
Name Type Description
full boolean Return complete content items instead of the id only.
tags string,object(json) Tags Key/(string)values map.
op "AND", "OR" The operation for tags filters logic.
limit integer {1..2000} Approximate number of items to return (Default = 1000).
recursive boolean Return items nested in sub-folders (keys containing '/') (Default = true).
prefix string Only returns items starting with the given prefix.
cursor string Pagination cursor: The last key returned by the previous page.

Responses

An array of content items

Content: [ object ]

Name Type Description
id string The id of the content item
tags object Tags and their values for the content item
tags.* string Tag value
type string The mime type of the content item
length integer The content item's length in bytes
last_modified string(dateTime) Last modified timestamp (formatted as ISO 8601)
An error occurred

Content: object Error information

Name Type Description
type string The error message's type
message string The associated error message

Example

response.message = Content.list({
  full = true
})
-- or
response.message = Content.list({
  tags = to_json({mykey = "myvalue"})
})
-- or
response.message = Content.list({
  tags = to_json({mykey = "myvalue", mykey2 = "myvalue2"}),
  op = "OR"
})

upload

Get the upload URL for the specified content item. The content ID will be generated if not supplied, and can be generated using the key, if provided

Arguments

parameters - object - Object containing service call parameters.
Name Type Description
id string The content unique ID
md5 string The md5 sum of the content to upload
type string The content's type
expires_in ^[0-9]+$ Time duration in seconds or URL validity
tags string,object(json) Tags Key/(string)values map.

Responses

The upload URL

Content: object HTTP information for client-side content uploads

Name Type Description
id string The id of the content item
url string The URL to use
field string The name of the part containing upload data (must be LAST)
inputs object Additional parts expected with the upload
method "POST" The HTTP method to use with this URL
enctype string The expected form-data encoding to use
An error occurred

Content: object Error information

Name Type Description
type string The error message's type
message string The associated error message

Example

local filename = "image.png" local file_type = "image/png" local expires_in = 600
local presigned_upload = Content.upload({
  id = filename,
  type = file_type,
  expires_in = expires_in,
})
-- Create curl upload command local curl_command = "curl"
for k, v in pairs(presigned_upload.inputs) do
  curl_command = curl_command .. " -F \"" .. k .. "=" .. v .."\""
end -- This assumes the file exist in the same directory as curl is being called from. curl_command = curl_command .. " -F file=@" .. filename .. " " .. presigned_upload.url
return curl_command