API Reference for Nhost Storage

EndpointMethodDescription
/storage/o/<path>GETGet file
/storage/m/<path>GETGet file metadata
/storage/o/<path>/GETGet ZIP of all files in folder
/storage/m/<path>/GETGet metadata of all files in folder
/storage/o/<path>/POSTUpload file
/storage/o/<path>/DELETEDelete file

#Get file

Get file

nhost-js-sdk

Not needed, just access the file directly

Request

GET /storage/o/<path-to-file>

Response

<file>

#Get file metadata

Get file metadata

nhost-js-sdk

storage.getMetadata(path: string);

Request

GET /storage/m/<path>

Response

{
  "key": "<path-to-file>",
  "AcceptRanges": "bytes",
  "LastModified": "2020-01-01T01:02:03.000Z",
  "ContentLength": 12345,
  "ETag": "Etag",
  "ContentType": "<content-type>",
  "Metadata": {
    "token": "<auto-generated-access-token-uuid>"
  }
}

#Get zip of all files in folder

Get zip of all files in folder.

nhost-js-sdk

Just access the path directly.

Request

GET /storage/o/<path>/

Response

Downloadable list.zip file

#Get metadata of all files in a folder

Get metadata of all files in a folder.

nhost-js-sdk

storage.getMetadata(path: string);

Request

GET /storage/m/<path>/

Response

[
  {
    "key": "<path-to-file>",
    "AcceptRanges": "bytes",
    "LastModified": "2020-01-01T01:02:03.000Z",
    "ContentLength": 12345,
    "ETag": "Etag",
    "ContentType": "<content-type>",
    "Metadata": {
      "token": "<auto-generated-access-token-uuid>"
    }
  },
  {
    "key": "<other-path-to-file>",
    "AcceptRanges": "bytes",
    "LastModified": "2020-05-04T03:02:01.000Z",
    "ContentLength": 54321,
    "ETag": "Etag",
    "ContentType": "<content-type>",
    "Metadata": {
      "token": "<auto-generated-access-token-uuid>"
    }
  }
]

#Upload file

Upload file.

nhost-js-sdk

storage.put(path: string, file: File);
```

### Request

`POST /storage/o/<path-to-file>`

### Response

```json
{
  "key": "<path-to-file>",
  "AcceptRanges": "bytes",
  "LastModified": "2020-01-01T01:02:03.000Z",
  "ContentLength": 12345,
  "ETag": "Etag",
  "ContentType": "<content-type>",
  "Metadata": {
    "token": "<auto-generated-access-token-uuid>"
  }
}

#Delete file

Delete file.

nhost-js-sdk

storage.delete(path: string);
```

### Request

`DELETE /storage/o/<path-to-file>`

### Response

```bash
204 No Content