Guide to uploading files directly from command line
Brendan G · 2026-04-19
Guide to Uploading Files Directly from Command Line
Introduction to Uploading Files Directly from Command Line
Uploading files directly from the command line is a powerful feature that can save you time and increase productivity. With FileShot.io, you can upload files from your local machine to our cloud storage platform using the command line interface. This feature is especially useful for developers, system administrators, and power users who need to automate file transfers or integrate FileShot.io with their existing workflows.Why Uploading Files from Command Line Matters
Uploading files from the command line offers several benefits, including:- Automation**: Automate file transfers and workflows by integrating FileShot.io with your command line scripts.
- Productivity**: Save time by uploading files directly from the command line, eliminating the need to use graphical user interfaces.
- Flexibility**: Upload files from anywhere, at any time, using the command line interface.
- Integration**: Integrate FileShot.io with your existing workflows and tools, such as continuous integration/continuous deployment (CI/CD) pipelines.
Prerequisites for Uploading Files from Command Line
Before you start uploading files from the command line, you need to ensure that you have the following prerequisites:- A FileShot.io account**: Create a FileShot.io account to access our cloud storage platform.
- FileShot.io API credentials (Client ID and Client Secret)**: Obtain your API credentials to authenticate and authorize with FileShot.io.
- The `curl` command-line tool**: Install the `curl` command-line tool on your system to make HTTP requests.
- The `jq` command-line tool (optional)**: Install the `jq` command-line tool to create JSON payloads with file metadata.
Authentication and Authorization
To upload files from the command line, you need to authenticate and authorize with FileShot.io using your API credentials. You can do this by creating a personal access token (PAT) on the FileShot.io dashboard. Here's how to do it:- Log in to your FileShot.io account**: Navigate to the FileShot.io dashboard and log in to your account.
- Navigate to the "API" section**: Click on the "API" section to access your API credentials.
- Click on "Generate Personal Access Token"**: Click on the "Generate Personal Access Token" button to create a new PAT.
- Enter a name for your token**: Enter a name for your PAT to identify it later.
- Click on "Generate Token"**: Click on the "Generate Token" button to create your PAT.
- Copy the generated token**: Copy the generated token and store it securely.
Uploading Files using the `curl` Command-Line Tool
Now that you have authenticated and authorized with FileShot.io, you can start uploading files using the `curl` command-line tool. Here's an example of how to upload a file from your local machine: ```bash curl -X POST \ https://api.filesot.io/v1/files \ -H 'Authorization: Bearer YOUR_PAT' \ -H 'Content-Type: application/json' \ -T example.txt ``` This command uploads the `example.txt` file from your local machine to FileShot.io. You can replace `example.txt` with the path to the file you want to upload.Uploading Files using the `jq` Command-Line Tool (Optional)
If you want to upload files in a more structured way, you can use the `jq` command-line tool to create a JSON payload with the file metadata. Here's an example of how to do it: ```bash jq -n --arg file_name "example.txt" --arg file_content "Hello, World!" '{file: {name: $file_name, content: $file_content}}' | curl -X POST \ https://api.filesot.io/v1/files \ -H 'Authorization: Bearer YOUR_PAT' \ -H 'Content-Type: application/json' \ -d @- ``` This command creates a JSON payload with the file metadata using `jq` and then uploads the file to FileShot.io using `curl`.Best Practices for Uploading Files from Command Line
Here are some best practices to keep in mind when uploading files from the command line:- Use secure authentication**: Use secure authentication methods, such as OAuth or JWT, to authenticate with FileShot.io.
- Handle errors**: Handle errors and exceptions that may occur during file uploads.
- Validate file metadata**: Validate file metadata to ensure that it conforms to FileShot.io's requirements.
- Test your scripts**: Test your scripts thoroughly to ensure that they work as expected.
Conclusion
Uploading files directly from the command line is a powerful feature that can save you time and increase productivity. With FileShot.io, you can upload files from your local machine to our cloud storage platform using the command line interface. By following the steps outlined in this guide, you can start uploading files directly from the command line using FileShot.io.Join the affiliate program and earn 50%. No approvals, no waitlists.