Skip to content

Working with files

Files are uploaded, listed, downloaded or deleted in UbiOps using an API request, either directly or using the WebApp, CLI or Python client library. In the WebApp you can browse through existing files, upload new files, or organize them in folders. When using the WebApp, the uploading of the file and passing the URI in the deployment request is handled automatically in the background.

See platform limits for limitations on the usage of files.

Uploading & downloading files from UbiOps

upload file

To support the process of uploading and downloading files, we have added relevant helper functions to our Python client in a module named ubiops.utils. The module contains the methods ubiops.utils.download_file and ubiops.utils.upload file. These methods can be used to download or upload a file in one step. The following example uses the API Client api_client to upload/download a file file to the location files/file in bucket my-bucket in project my-project.

When using the WebApp, the uploading of the file and passing the URI in the deployment request is handled automatically in the background.

from ubiops import utils

#Upload a file
file_uri = ubiops.utils.upload_file( 
  client = api_client, #a UbiOps API client 
  project_name = "my-project", 
  file_path = "file", 
  bucket_name = "your-bucket", 
  file_name = "files/file" 
)
from ubiops import utils

#Download a file
file_uri = ubiops.utils.download_file(
  client = api_client, #a UbiOps API client, 
  project_name= "my-project", 
  output_path = "file"
  bucket_name= "your-bucket",
  file_name= "files/file"
)

In the WebApp a download button is available after completing a request or by navigating to a file in your bucket.

Alternatively, you can use the API directly to download or upload files. When using the API directly to download or upload files, please note that it is a two-step process that uses "signed URLs".

For downloading:

  • Request a signed URL using the "Download a file" API endpoint.
  • Download the file using a standard HTTP GET request.

For uploading:

  • Request a signed URL using the "Upload a file" API endpoint.
  • Use the signed URL to upload the file using an HTTP PUT upload request. An example using cURL is: curl -X PUT <signed URL> --upload-file file.ext.
  • Azure buckets require two additional request headers to be sent with the upload, see the "Upload a file" endpoint on our Swagger documentation for more information.

A signed URL is valid for 5 minutes. Note that anyone in possession of this URL can upload or download the file during the 5-minute window.

File operations

Some examples on how to perform typical file operations on UbiOps: