Objective
Uploading a private asset isn’t supported in the Assets Plugin, uploads are public by default. This article explains how to upload an asset as private using the Functions & Assets Twilio Console.
Product
Twilio Assets
Environment
legacy Twilio Console
Procedure
To upload an asset as private, one first needs to create the asset and then create a corresponding asset version where its visibility is set to private. For example, to upload a file named Twilio.png as a private asset, one would perform the following steps:
Create an Asset
curl -X POST "https://serverless.twilio.com/v1/Services/ZSxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/Assets" \ --data-urlencode "FriendlyName=FriendlyName" \ -u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
- This first step returns a response that includes your asset SID (
ZSxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx).
Create a Corresponding Asset Version
curl -X POST "https://serverless-upload.twilio.com/v1/Services/ZSxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/Assets/ZHxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/Versions" \ -F "Content=@my-asset.png; type=image/png" \ -F "Path=/my-asset.png" \ -F "Visibility=private" \ -u "TWILIO_API_KEY:TWILIO_API_SECRET"
Note: Please make sure to execute the above command in the same folder where the asset is located. Otherwise, a curl: (26) Failed to open/read local data from file/application error will be given.
Additional Information
More information about assets can be found at the following links: