Skip to main content

/images/icons/xs_temp.svg Create Image Metadata

storage.create_image {
  access = "public"
  value = $input.file
  filename = ""
} as image_metadata
ParameterPurposeExample
accessAccess level for the stored imagepublic, private
valueSource file to create image from$input.file, $file.data
filenameName for the stored image file"profile.jpg", "avatar.png"
asAlias to reference the image metadataimage_metadata, uploaded_image
storage.create_image {
  access = "public"
  value = $input.profile_photo
  filename = "user_"|add:$user.id|add:"_profile.jpg"
} as profile_image
  • Creates metadata about the stored image
storage.create_image {
  access = "private"
  value = $input.profile_photo
  filename = "user_"|add:$user.id|add:"_private.jpg"
} as private_profile_image
  • Stores the image as private (requires signed URL to access)

/images/icons/xs_temp.svg Create Video Metadata

storage.create_video {
  access = "public"
  value = $image_metadata
  filename = ""
} as x1
ParameterPurposeExample
accessAccess level for the stored videopublic, private
valueSource file to create video from$input.video, $file.data
filenameName for the stored video file"video.mp4", "recording.mov"
asAlias to reference the video metadatax1, video_data
storage.create_video {
  access = "public"
  value = $input.video_upload
  filename = "video_"|add:$timestamp|add:".mp4"
} as uploaded_video
  • Creates metadata for a video file

/images/icons/xs_temp.svg Create Audio Metadata

storage.create_audio {
  access = "public"
  value = $input.file
  filename = ""
} as x2
ParameterPurposeExample
accessAccess level for the stored audiopublic, private
valueSource file to create audio from$input.file, $audio.data
filenameName for the stored audio file"recording.mp3", "audio.wav"
asAlias to reference the audio metadatax2, audio_data
storage.create_audio {
  access = "public"
  value = $input.audio_upload
  filename = "audio_"|add:$timestamp|add:".mp3"
} as uploaded_audio
  • Creates metadata for audio file

/images/icons/xs_temp.svg Create Attachment Metadata

storage.create_attachment {
  access = "public"
  value = $input.file
  filename = ""
} as x3
ParameterPurposeExample
accessAccess level for the stored attachmentpublic, private
valueSource file to create attachment from$input.file, $document.data
filenameName for the stored attachment"document.pdf", "spreadsheet.xlsx"
asAlias to reference the attachment metadatax3, file_data
storage.create_attachment {
  access = "public"
  value = $input.document
  filename = "file_"|add:$user.id|add:"_"|add:$original_filename
} as uploaded_file
  • Creates metadata for the attachment

/images/icons/xs_temp.svg Create File Resource

storage.create_file_resource {
  filename = "filename.ext"
  filedata = "filedata"
}
ParameterPurposeExample
filenameName of the file to create"document.txt", "data.json"
filedataContent of the file"Hello World", $encoded_data
storage.create_file_resource {
  filename = "export_"|add:$timestamp|add:".csv"
  filedata = $processed_data|to_csv
}
  • Creates a file resource from provided data

/images/icons/xs_temp.svg Get File Resource Data

storage.read_file_resource {
  value = $input.file
} as file2
ParameterPurposeExample
valueFile resource to read$input.file, $stored_file.id
asAlias to reference the file contentsfile2, file_contents
storage.read_file_resource {
  value = $stored_document.id
} as document_contents
  • Reads contents of a stored file resource

/images/icons/xs_temp.svg Delete File

storage.delete_file {
  pathname = "/path/to/file.ext"
}
ParameterPurposeExample
pathnamePath to the file to delete"/path/to/file.ext", $file.path
storage.delete_file {
  pathname = "/uploads/"|add:$file.name
}
  • Deletes a file from the specified path
  • Requires full path to the file
  • Permanently removes the file
  • Use with caution as deletion cannot be undone

/images/icons/xs_temp.svg Sign Private File URL

storage.sign_private_url {
  pathname = "/path/to/privatefile.ext"
  ttl = 30
} as x4
ParameterPurposeExample
pathnamePath to the private file"/path/to/privatefile.ext", $file.path
ttlTime-to-live in seconds for the signed URL30, 3600, 86400
asAlias to reference the signed URLx4, signed_url
storage.sign_private_url {
  pathname = $private_file.path
  ttl = 3600
} as temporary_url
  • Generates a temporary signed URL for accessing private files

Notes on Returned Metadata

All storage.create_* functions return a metadata object with fields such as:
  • id: Unique identifier for the file resource
  • name: File name
  • size: File size in bytes
  • mime: MIME type
  • path: Storage path
  • url: Public URL (if access is public)
  • created_at: Timestamp
Refer to the XanoScript documentation for the full schema.

Error Handling Example

If you attempt to read or delete a file that does not exist, Xano will throw an error. You can handle this with try_catch:
try_catch {
  try {
    storage.read_file_resource {
      value = $input.file
    } as file_contents
  }
  catch {
    debug.log {
      value = "File not found or could not be read."
    }
  }
}
I