How to Make a Cloud File Sharing Using Python

Cloud storage and file sharing have become essential tools for developers and users alike. Whether I’m sending files to clients, backing up documents, or collaborating with teammates, I often find myself needing a quick, no fuss way to upload and share files.

I’ll walk you through how I use the gofile Python package to upload files to the cloud and get instant download links. No browser.

I’ll also enhance the script so it can handle multiple files, display friendly messages, and even copy the download links to my clipboard automatically.

Installation Command

Before we write any code, we need to install the gofile package. You can do that easily using pip:

pip install gofile

If you want clipboard functionality later on (totally optional but super useful), install pyperclip too:

pip install pyperclip

My First Cloud Upload Script

Here’s the original version I started with:

# File Storage
import gofile as go

def Store_Files(file):
cur_server = go.getServer()
print(cur_server)
url = go.uploadFile(file)
print("Download Link:", url["downloadPage"])

Store_Files("clcoding.pdf")

Explain Code

  • import gofile as go: Loads the gofile library.
  • go.getServer(): Finds the best available server for uploading.
  • go.uploadFile(file): Uploads the selected file.
  • url["downloadPage"]: Extracts the public download URL.

Example Output:

{'server': 'store10'}
Download Link: https://gofile.io/d/DDBEvC

But this only handles one file. And what if the file is missing, Or the server is down? I decided to level it up.

Enhance Version With Practical Feature

In the real world, I often need:

The ability to upload multiple files
Error handling in case something goes wrong
Copying the link to clipboard for quick pasting
Friendly and clear status messages

Full Python Script

import gofile as go
import os
import pyperclip # Optional: for copying link to clipboard

def store_files(file_paths):
try:
server = go.getServer()
print(f" Connected to Server: {server['server']}")
except Exception as e:
print(" Failed to get server:", e)
return

for file in file_paths:
if os.path.isfile(file):
try:
print(f"\n Uploading '{file}'...")
result = go.uploadFile(file)
download_link = result["downloadPage"]
print(f" Uploaded successfully: {download_link}")

# Optional: Copy link to clipboard
pyperclip.copy(download_link)
print("📎 Download link copied to clipboard.")

except Exception as upload_error:
print(f" Failed to upload '{file}': {upload_error}")
else:
print(f" File not found: {file}")

# Example usage
files_to_upload = ["clcoding.pdf", "example.txt"]
store_files(files_to_upload)

Clipboard Support

To enable clipboard copying (which saves me SO much time), don’t forget to install pyperclip:

pip install pyperclip

Final Thought

As a Python developer, I love building tools that simplify my workflow and this script is now a go-to in my toolkit. Whether I’m working on a team project or just need to send a quick file to a friend, I can run a single script and get a shareable cloud link instantly.

Related blog posts