DEV Community

Free Python Code
Free Python Code

Posted on

Upload up to 1GB to filestack API and Python

Hi πŸ™‚πŸ–

Welcome in a new post, today i will to use filestack API to upload files to it.

step 1

To upload file to filestack you need to create account in filestack and install filestack
create account : https://dev.filestack.com/signup/free/
pip install filestack-python

step 2

Create main.py and .env to store the API-key
get your API-key from your dashboard

Image description

paste the API-key into .env file

.env file

API_KEY = xxxxxxxxxxxxxxx
Enter fullscreen mode Exit fullscreen mode

main.py

from filestack import Client
import dotenv
import os

dotenv.load_dotenv()

API_KEY = os.getenv('API_KEY')

client = Client(API_KEY)

new_filelink = client.upload(filepath = 'imgs/alone.jpg')
print(new_filelink.url)
Enter fullscreen mode Exit fullscreen mode

result

https://cdn.filestackcontent.com/WbkCe47QqSsr5rghkygY
Enter fullscreen mode Exit fullscreen mode

Now we're done πŸ€—

Don't forget to like and follow πŸ™‚

Support me on PayPal πŸ€—
https://www.paypal.com/paypalme/amr396

For more information :
https://github.com/filestack/filestack-python

Top comments (0)