Files
Public Files
Public files can be uploaded from the API and are automatically distributed through a global content delivery network.
In return you will receive a JSON object containing a fileUrl that looks something like this:
//file-openchannel.netdna-ssl.com/555bfb9cc434df81e597598b.png
File URLs have a generic protocol and do not start with ‘http:’ or ‘https:’
This allows the URL to become compatible with the native protocol of the serving web page. However, in some instances it may be necessary to pre-pend ‘http:’ or ‘https:’ to the URL.
There are two available methods for uploading files. You can either upload a file directly to the API using multipart form data or you can supply a URL and the OpenChannel platform will download the file.
After uploading a file, add the fileUrl to any app, review, user or developer’s customData object.
Add the fileUrl to a customData field.
Any files that do not have a URL within an app, user, developer, or review customData field will be deleted after a few days.
For example, here is an app with a file attached to an app’s customData.icon field:
{
"appId": "5565322ae4b0a70b13a4563b",
"name": "my first app",
"developerId": "123",
"customData":
{
"summary": "Automatically set on/off timers...",
"description": "HPWHs use electricity to move heat...",
"icon": "//cdn.openchannel.io/files/55653202e4b0a70b13a4562d.jpg"
},
...
}
Private Files
Private files can be uploaded from the API and are automatically distributed through a global content delivery network. Unlike with public files, private files are not publicly accessible and do not have an associated fileUrl. Instead, it’s required that the Download File API method be called in order to get a signed, short lived URL which a user can use to download the file.
Since the signed URLS can only be used for a few seconds, the best way to implement file download is:
- The user clicks on a link or requests to download the file
- Your back end service calls the Download File API to generate a signed URL
- Redirect the user to the signed URL or use javascript to initiate the download
Don’t display signed URL’s as links on webpages.
Signed URLs are only usable for a few seconds so they shouldn’t be placed directly on webpages. Instead, they should be generated and used when the user has already decided to perform the “download” action.
After uploading a file, add the fileId to any app, review, user or developer’s customData object.
Add the fileId to a customData field.
Any files that do not have a fileId within an app, user, developer, or review customData field will be deleted after a few days.
For example, here is an app with a file attached to an app’s customData.myFile field:
{
"appId": "5565322ae4b0a70b13a4563b",
"name": "my first app",
"developerId": "123",
"customData":
{
"summary": "Automatically set on/off timers...",
"description": "HPWHs use electricity to move heat...",
"myFile": "59b0100dca753d5ed65578bb/private/55653202e4b0a70b13a4562d.jpg"
},
...
}