files

Replace file

Replace an existing file with new content while preserving the file ID. The operation follows these steps:

  1. The isUploaded flag is set to false to mark the file as being updated
  2. The file content is replaced in the storage backend
  3. File metadata is updated (size, mime-type, isUploaded, etc.)

Each step is atomic, but if a step fails, previous steps will not be automatically rolled back.

put/files/{id}

Request

  • Base URL
    https://{subdomain}.storage.{region}.nhost.run/v1
  • URL
    https://{subdomain}.storage.{region}.nhost.run/v1/files/{id}
  • Auth
    HTTP bearer

Path parameters

idstring required

Unique identifier of the file to replace

Request body multipart/form-data

filestring binary

New file content to replace the existing file

Example request

{
  "metadata": {
    "name": "renamed-file.jpg",
    "metadata": {
      "alt": "Updated image description",
      "category": "profile"
    }
  }
}

Response

File successfully replaced

idstring required

Unique identifier for the file.

namestring required

Name of the file including extension.

sizeinteger required

Size of the file in bytes.

bucketIdstring required

ID of the bucket containing the file.

etagstring required

Entity tag for cache validation.

createdAtstring date-time required

Timestamp when the file was created.

updatedAtstring date-time required

Timestamp when the file was last updated.

isUploadedboolean required

Whether the file has been successfully uploaded.

mimeTypestring required

MIME type of the file.

uploadedByUserIdstring

ID of the user who uploaded the file.

metadataobject

Custom metadata associated with the file.

Example response

{
  "id": "d5e76ceb-77a2-4153-b7da-1f7c115b2ff2",
  "name": "profile-picture.jpg",
  "size": 245678,
  "bucketId": "users-bucket",
  "etag": "\"a1b2c3d4e5f6\"",
  "createdAt": "2023-01-15T12:34:56Z",
  "updatedAt": "2023-01-16T09:45:32Z",
  "isUploaded": true,
  "mimeType": "image/jpeg",
  "uploadedByUserId": "abc123def456",
  "metadata": {
    "alt": "Profile picture",
    "category": "avatar"
  }
}

Changes

No recorded changes to this operation across all 7 revisions of this API.