Overview
Uploading a file to Oxen involves three main steps:- Create a repository (if it doesn’t exist)
- Upload the file to a specific branch
- Optionally create additional branches from the uploaded content
Prerequisites
Before you begin, you’ll need:- API Key: Authentication token for your Oxen account
- Server URL: The Oxen server endpoint (e.g.,
https://hub.oxen.aior your local server) - File to upload: The local file you want to add to your repository
Configuration
First, set up your configuration variables:Step 1: Create a Repository
Create a new repository to store your files. If the repository already exists, this step will return a 409 status code and you can continue.Endpoint
Example
Request Body
Response
Step 2: Upload a File
Upload a file to your repository. This creates a commit on the specified branch with your file.Endpoint
Path Parameters
Example
Request Body (Multipart Form Data)
Note: You can upload multiple files in a single request by including multiple
file fields with different filenames.
Response
Step 3: Create a Branch (Optional)
After uploading files, you can create additional branches from your main branch.Endpoint
Example
Request Body
Response
Complete Example
Here’s a complete Python script that ties everything together:Authentication
All API requests require authentication using a Bearer token in the Authorization header:Getting an API Key
- Log in to your Oxen account at hub.oxen.ai
- Navigate to your account settings
- Generate a new API key
Advanced Usage
Uploading Multiple Files
You can upload multiple files in a single request by including multiplefile fields:
Uploading to Different Branches
Organizing Files in Directories
Files are automatically organized based on theremote_file_path:
Next Steps
- Download Files - Learn how to retrieve files
- List Files - Browse repository contents
- Workspaces - Work with remote data without downloading
- Branches - Manage repository branches