Add downloadable files to a product edition
About downloadable files
Partners have the option to include downloadable files with a product edition. On Workspace, users can download these files directly to their computers.
To make downloadable files available to users, partners can either upload files directly to partner storage or provide a URL to a separate file location. Both options require uploading a configuration file to partner storage.
Upload downloadable files to partner storage
This task shows you how to upload files to partner storage using cURL.
Prerequisites
- Ensure you have an pull secret and the bucket name on partner storage.
Procedure
-
To connect to partner storage, using your pull secret, generate an access token using the following command.
curl -X "POST" "https://iam.cloud.ibm.com/oidc/token" \-H "Accept: application/json" \-H "Content-Type: application/x-www-form-urlencoded" \--data-urlencode "apikey=$(echo "{pull_secret}" | cut -d'.' -f2 | base64 --decode | sed -n 's|.*"iam_apikey":"\([^"]*\)".*|\1|p')" \--data-urlencode "response_type=cloud_iam" \--data-urlencode "grant_type=urn:ibm:params:oauth:grant-type:apikey" -
To upload files, using your access token, run the following command.
curl -X "PUT" "https://s3.us.cloud-object-storage.appdomain.cloud/(bucket-name)/(file-path)" \-H "Authorization: bearer (token)" \--data-binary @'<file_path_from_your_drive>'
Result
You uploaded files to partner storage. On terminal, a successful upload returns to the command prompt with no error message showing. Larger files will take more time to complete, so be patient.
Next steps
Publish the product edition.
Related links
For more commands, refer to Using cURL on IBM Cloud Object Storage.
Example upload file request
The following shows an example request to upload files to partner storage.
curl -X "PUT" "https://s3.us.cloud-object-storage.appdomain.cloud/rhm-sand-edition-200321/sampledata/sampledata_file.csv" \-H "Authorization: bearer (token)" \--data-binary @'/Users/Downloads/sampledata_file.csv'
Note: On terminal, a successful upload returns to the command prompt with no error message showing.
Get bucket name
To upload downloadable files to partner storage, you need the bucket name on partner storage. The bucket name shows, on product pricing setup, on the Add a dataset to the edition section.
About metadata.json for downloadable files
Metadata.json contains information about the downloadable files, such as file
path, version, and last update. To successfully onboard downloadable files, you
must upload metadata.json
along with your downloadable files to partner storage.
Note: When uploading downloadable files to more than one bucket, you must include one metadata.json file per bucket.
Metadata.json for downloadable files field descriptions
The following shows descriptions for metadata.json fields.
version
— the date and time of the last uploadsequence
— indicates the amount of times partners uploaded filesfiles
— contains an array of file detailsfileName
— the complete path to the file, when the file has been uploaded to partner storage. Use the same file path that you used to upload the files.name
— the file name. Shows on WorkspacefileType
— the file format. Shows on Workspaceversion
— the current file version. Shows on Workspace.fileLength
— the file size in bytes. A representation shows on Workspace.lastUpdatedDate
— the date of the most recent file update. Shows on Workspace.url
— the complete path to the file, when the file is hosted in a different location, outside of partner storage.
Sample metadata.json for downloadable files
The following shows a sample metadata.json
. To enable downloadable files for
users, ensure you upload the file to partner storage.
{"data": {"contents": [{"version": "2021-02-12T09:40:41.342Z","sequence": 4629,"files": [{"fileName": "sampledata/sampledata_file.csv","name": "sampledata_file","fileType": "csv","version": "1","fileLength": 14666026,"lastUpdatedDate": 1613008916000},{"fileName": "sampledata/sampledata_file.json","name": "sampledata_file","fileType": "json","version": "1","fileLength": 14666026,"lastUpdatedDate": 1613008919000},{"url": "https://dax-cdn.cdn.appdomain.cloud/dax-noaa-weather-data-jfk-airport/1.1.4/noaa-weather-data-jfk-airport.tar.gz","name": "noaa-weather-data-jfk-airport","fileType": "tar","version": "1","fileLength": 14735883,"lastUpdatedDate": 1613008920000}]}]}}
Example metadata.json upload file request
The following shows an example request to upload metadata.json directly to partner storage.
curl -X "PUT" "https://s3.us.cloud-object-storage.appdomain.cloud/rhm-sand-edition-200321/metadata.json" \-H "Authorization: bearer (token)" \--data-binary @'/Users/Downloads/metadata.json'
Note: On terminal, a successful upload returns to the command prompt with no error message showing.