Python Project : Free File Storage Tool

0

Hey there, Hope you are having a great day. In this Python tutorial, you will see how you can send file to a free remote server and then download it later.

python project to store file in api

How to send the file to a Free Server

We can send our file to a remote server by using the API of the remote server

To send a file to a remote server :

  1. import requests module in python
  2. set the path of the file
  3. make a request to the API
  4. get the URL of the file

Once the program is run. It will return a URL for the file. You can browse that URL and find the file for the download.

Make sure you have installed the requests library in python.

See the following python code example that uploads a file to a remote server and acts like a free file storage


import requests

files = {
    'file': ('file.txt', open('file.txt', 'rb')),
}

url = 'https://api.anonfiles.com/upload'
response = requests.post(url, files=files)

data = response.json()

print(data['data']['file']['url']['short'])

Also watch this video tutorial on How to run this Project

Summary and Keynotes

In this article, you have to build a project that actually stores files on the cloud.

YOu have learned the following key concepts

  • Sending files to the server
  • using requests library
  • Post request in Python

Leave a question that you have in your mind. I will answer it in a blank

Post a Comment

0Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !