Modify Object


Prerequisites

To follow this guide, you will need access to your SpinUp account Control Panel. If you want to modify an object’s metadata rather than the object itself, you need access to a RESTful API client such as Postman, or cURL commands sent via a terminal, and some basic knowledge of how API communications work.

Modify an object’s contents

Confirm you are in the desired project on your account before starting–if you only have one project, this is picked by default. In the left-hand menu, navigate to the Object Storage section of your SpinUp Control Panel.

Select a region and a bucket

Select which region contains the version of your object to be modified by picking from the Region drop-down menu at the top of this screen. Next, click on the name of the bucket that contains the object to view the contents.

Locate the object to modify

If the object you wish to modify is located inside of a virtual folder, navigate to that specific folder before you re-upload your file. If you are uncertain of the exact object name or location, you can use the search bar to locate your object by all or part of the file name or virtual folder name.

Upload the new object version

Click on the Upload File icon at the correct location for the existing object, and either browse or drag and drop the replacement file of the same name to the pop-up box. Once the upload is completed, the progress pop-up will automatically close.

Modify an object’s HTTP headers

If you wish to add or modify the metadata headers for an object already in storage, this can be performed via the API. Object Storage supports several built-in headers to support certain features, or you can set custom headers for use with your applications. For this guide, the built-in X-Delete-At header will be added, which causes an object to automatically expire and get deleted from storage on a date set in epoch time.

Obtain an API token

Obtain an API token by requesting it from the identity service using your account credentials, account ID, and the project ID you will be working in. This will differ between SpinUp account users and API-only users–please see the API documentation for further information.

  

curl -i -X POST https://api.spinup.com/identity/v1/tokens -d '{"email": "[email protected]","password": "7+#9G?7+Fz3xQ$DNC","account_id": "AB1CD3","project_id": "abab0202-abcd6-4bee-a92a-d8e533a45678"}' -H "Content-Type:application/json"

HTTP/1.1 201 CREATED
...

{"account_id":"AB1CD3","expires":"2019-12-19T16:41:26","id":"AAAAAAAAA__abcabcdabcd0000-cdcd4545_z4","project_id":"cabab0202-abcd6-4bee-a92a-d8e533a45678"","user_id":"123456-abab-1212-5e5e-cb6677cb"}


Make a POST API request to the object

Make a POST request to the object by including its full path (bucket name, any virtual folder paths, and the object name) after the endpoint URL. Include the header you wish to create or modify on the file. In this example $token is your token obtained in the previous step, and $url is the unique endpoint URL for your account and project in the desired region:

  

curl -i -X POST -H X-Auth-Token:$token -H X-Delete-At:1577292649 $url/test1/tinypotato.png
HTTP/1.1 202 Accepted
Content-Length: 76
Content-Type: text/html; charset=UTF-8
X-Trans-Id: txbbbb70253cd34f9c970e0-005dfa5918uscentral1
Date: Wed, 18 Dec 2019 16:51:37 GMT
...

Accepted

The request is accepted for processing.

When performing a HEAD request for the object, the new header is now displayed:

  

curl --head -H X-Auth-Token:$token $url/test1/tinypotato.png
HTTP/1.1 200 OK
Content-Length: 173106
X-Delete-At: 1577292649
Accept-Ranges: bytes
Last-Modified: Wed, 18 Dec 2019 16:51:38 GMT
Etag: be9d70c2399a6cd51126ddbe111cc196
X-Timestamp: 1576687897.43892
Content-Type: image/png
X-Trans-Id: txcccc766a26f4f849e872-005dfa5923uscentral1



Related Content