How to update an object from an Edge Storage bucket
This guide walks you through updating an object from an Edge Storage bucket using the Azion API, Azion CLI, and Azion Runtime.
Updating an object from a bucket
Run the following PUT
request in your terminal, replacing [TOKEN VALUE]
with your personal token, <bucket_name>
with the name of the bucket, <object_key>
with the key of the object, and path/file.src
with the path to your new file:
curl --location --request PUT 'https://api.azion.com/v4/storage/buckets/<bucket_name>/objects/<object_key>' \
--header 'Accept: application/json' \
--header 'Authorization: Token [TOKEN VALUE]' \
--header 'Content-Type: application/octet-stream' \
--data '@'
You should receive a response similar to this:
{ "state": "executed", "data": { "object_key": "people-100.txt" }
}
Requirements
To update a bucket:
Azion CLI will present a series of interactions, so the object can be updated. Run azion update edge-storage bucket -h
for further information about the data that can be updated.
You can create an edge function to update an object from your bucket. To do so:
- Access Azion Console > Edge Functions.
- Click the + Edge Function button.
- Name your function. Example:
object-update
. - In the Code tab, add the following JavaScript code, passing your bucket’s name and the object key:
- Click the Save button.
Once you have the edge function ready, you need to create an edge application that will proxy the process for the bucket and instantiate the edge function.
Go to Edge Application first stepsGo to how to instantiate an edge function