Cloud Storage
Last updated
Last updated
safekeepingCloud Storage Functions allow you to interact with Cloud Storage providers such as Google Cloud Storage directly in the function stack.
Leveraging a Cloud Storage solution requires you to have an account with the external provider and gives you enhanced control over your file storage.
Manage Google Cloud Storage buckets directly in the Xano function stack.
You need to set up a Google Service Account in the Google Cloud Console.
Navigate to IAM & Admin and select Service Accounts.
Select + Create Service Account.
Be sure to include the following Roles for the Service Account:
Service Account User
Storage Admin
Storage Object Admin
Once the Service Account is created, select actions and Manage keys.
Then add a new key and select the JSON option.
Google will provide a JSON file for download. Open the file and copy the JSON key. Paste this into your Xano workspace either as an Environment Variable or as a variable in the function stack that you are using the Google Cloud Storage functions.
The JSON key must be entered as a text string. Do not import the key as JSON when adding it to Xano.
List the contents of a Google Cloud Storage Bucket.
Service Account - the JSON key, stored as text, from your Google Service Account
Bucket - the name of the Bucket you wish to access.
Path - the path you wish to see the contents of.
Generate a signed URL to provide limited permissions. These can be used with a TTL (time to live) similar to an expiring token.
Service Account - the JSON key, stored as text, from your Google Service Account
Bucket - the name of the Bucket you wish to access.
filePath - the path of the file you wish to generate the URL for.
Method - the HTTP method (GET or POST)
TTL - time to live, in seconds. (How long until the URL expires).
Upload a File to the specific Google Cloud Storage bucket.
Service Account - the JSON key, stored as text, from your Google Service Account
Bucket - the name of the Bucket you upload a file to.
filePath - the path and name of the file you wish to store in the bucket. For example "files/image1" will upload the image in the files folder and name it image1.
File - the file being uploaded. This should come from a file resource input or a file resource variable.
Delete a specific file from a Bucket.
Service Account - the JSON key, stored as text, from your Google Service Account
Bucket - the name of the Bucket that contains the file.
filePath - the path of the file you wish to delete from the Bucket.
Return the file resource as a variable in Xano, including the raw image. This can be used, for example, to send to another service if file transfer is needed.
Service Account - the JSON key, stored as text, from your Google Service Account
Bucket - the name of the Bucket that contains the file.
filePath - the path of the file you wish to create a variable of.
Turn your API endpoint into a redirect to the file by returning the data field from the return variable and setting a custom header of Content-Type with the mime of the file resource.
Here's an example return of Create Variable from File Resource:
If we return the raw image (data) and use a Set Header function to define Content-Type
the mime (in this example image/png
). We can have our endpoint URL redirect to the file.
From your AWS Developer Console, navigate to Security Credentials.
Scroll down to Access Keys and select Create access key unless you have an access key and secret already generated.
Select Command Line Interface (CLI) as the use case and choose next, optionally add a description, then create the access key.
Store the Access key and Secret access key in a safe place. It's recommended to save these in your Xano workspace as Environment Variables as they will be used in the Amazon S3 Cloud Storage Functions.
The s3 bucket name and region will also be required when calling the Amazon s3 Cloud Storage Functions.
When navigating to your s3 buckets, the bucket name can be found under name. The region is under region but only requires the identifier. For example, in the below image the bucket name is xano-s3-test and the region is us-west-2.
Lists the directory details of the specific Amazon s3 bucket.
Bucket - The name of the s3 bucket you want to get the details of.
Region - The region of the bucket.
Key - The access key
Secret - The secret access key
Next_page_token - optional. The next page token is provided in the response if there is a next page, use this value to get the next page of items. S3 buckets limit 1,000 items per page.
Creates a signed URL of the file to be shared with an expiration.
Bucket - The name of the s3 bucket you want to get the details of.
Region - The region of the bucket.
Key - The access key
Secret - The secret access key
File_key - The file key of the file. This can be found in the s3 bucket when selecting the file and finding Key. Additionally, the Key is listed in the payload for List Directory.
TTL - Time to live. How long, in seconds, the signed URL is viewable until it expires.
Upload a file to a specified Amazon S3 Bucket
Bucket - The name of the s3 bucket you want to get the details of.
Region - The region of the bucket.
Key - The access key
Secret - The secret access key
File_key - Optionally define the file key. If nothing is defined, one will be automatically assigned by Amazon S3.
File - The file being uploaded. This must come from a file resource input or file resource variable.
Delete a file from a specified S3 Bucket.
Bucket - The name of the s3 bucket you want to get the details of.
Region - The region of the bucket.
Key - The access key
Secret - The secret access key
File_key - The file key of the file you wish to delete.
Return the file resource as a variable in Xano, including the raw image. This can be used, for example, to send to another service if file transfer is needed.
Bucket - The name of the s3 bucket you want to get the details of.
Region - The region of the bucket.
Key - The access key
Secret - The secret access key
File_key - The file key of the file you wish to return the file resource as a variable.
The result, shown on the right-hand side of the above image returns an object with the file name, size, mime type, and raw image represented in the path data.
Check out the example above to return the image through an API request.
Manage storage containers from your Microsoft Azure account directly from the Xano function stack.
Please ensure you have a Microsoft Azure account. If you don't yet have an account sign up to Microsoft Azure and navigate to the Azure portal.
A storage account is required to store files on Azure. First, select Create a resource from the portal homepage.
Navigate to storage and select Create under storage account.
Fill out the required information in Basics, if you don't already have a resource group, create a new one.
Configure any additional settings and create the storage account once you're ready.
Once the resource is deployed, navigate to containers and create a new container.
After creating a container, you need to retrieve your account access key to use the Azure functions in Xano.
Find Access keys under Security + Networking on the left navigation bar. Select Show next to Key under key1. Copy the key and store it as an Environment Variable in Xano.
Do not share your access key. It is recommended to store your access key as an Environment Variable in Xano for safe keeping.
List directory will list the blobs, properties, and metadata in a container or at a specified path within the container.
account_name - Azure storage account name.
account_key - Azure Access Key.
conatiner_name - Container name within Azure storage account.
path - (Optional) Use this to specify a specific blob or folder within a container.
Creates a signed URL for a file with a specified time to live (TTL) or expiration.
account_name - Azure storage account name.
account_key - Azure Access Key.
conatiner_name - Container name within Azure storage account.
path - The path of the file to create a signed URL for.
ttl - Time to Live (in seconds); how long the signed URL is accessible.
Upload a file to an Azure blob container.
account_name - Azure storage account name.
account_key - Azure Access Key.
conatiner_name - Container name within Azure storage account.
filePath - The path name for the file being uploaded.
file - The file being uploaded. This must come from a file resource.
metadata - (Optional). Optionally include additional metadata with the file stored in object format.
Delete a file from an Azure blob container.
account_name - Azure storage account name.
account_key - Azure Access Key.
conatiner_name - Container name within Azure storage account.
filePath - The path name for the file being deleted.
Create a variable from a file resource in Azure to use it in the Xano Function Stack.
account_name - Azure storage account name.
account_key - Azure Access Key.
conatiner_name - Container name within Azure storage account.
filePath - The path name for the file being created as a variable.
Check out the example above of leveraging the Variable from File Resource in the Function Stack.
Get the metadata of a file from an Azure blob container.
account_name - Azure storage account name.
account_key - Azure Access Key.
conatiner_name - Container name within Azure storage account.
filePath - The path name for the file to retrieve the metadata from.