Skip to main content

Filestack REST API Library

Project description

<p align="center"><img src="logo.svg" align="center" width="100"/></p>
<h1 align="center">Filestack Python</h1>
<p align="center">
<a href="http://travis-ci.org/filestack/filestack-python">
<img src="https://img.shields.io/travis/filestack/filestack-python.svg">
</a>
<a href="https://pypi.python.org/pypi/filestack-python/2.3.1">
<img src="https://img.shields.io/pypi/v/filestack-python.svg">
</a>
</p>
This is the official Python SDK for Filestack - API and content management system that makes it easy to add powerful file uploading and transformation capabilities to any web or mobile application.

## Resources

* [API Reference](https://filestack.github.io/filestack-python)

## Installing

Install ``filestack`` with pip

```shell
pip install filestack-python
```

or directly from GitHub

```shell
pip install git+https://github.com/filestack/filestack-python.git
```

## Usage

The Filestack SDK allows you to upload and handle filelinks using two main classes: Client and Filelink.

### Uploading New File with Client
``` python
from filestack import Client
client = Client("<YOUR_API_KEY>")

params = {'mimetype': 'image/png'}
new_filelink = client.upload(filepath="path/to/file", params=params)
print(new_filelink.url)
```
Uploading local files will use Filestack's multipart upload by default. To disable, just set the argument to false.

```python
new_filelink = client.upload(filepath="path/to/file", multipart=False)
```
#### Uploading files using Filestack Intelligent Ingestion
To upload files using Filestack Intelligent Ingestion, simply add `intelligent=True` argument
```python
new_filelink = client.upload(filepath="path/to/file", intelligent=True)
```
FII always uses multipart uploads. In case of network issues, it will dynamically split file parts into smaller chunks (sacrificing upload speed in favour of upload reliability).

### Create Filelink using Existing Handle
```python
from filestack import Filelink
new_filelink = Filelink("<YOUR_HANDLE>")
```

### Basic Filelink Functions

With a Filelink, you can download to a local path or get the content of a file. You can also delete or overwrite files if you have security enabled on your account.

```python
file_content = new_filelink.get_content()

response = new_filelink.download("/path/to/file")

filelink.overwrite(filepath="path/to/new/file")

response = filelink.delete()
```

### Transformations

You can chain transformations on both Filelinks and external URLs. Storing transformations will return a new Filelink object.

```python
transform = client.transform_external('http://<SOME_URL>')
new_filelink = transform.resize(width=500, height=500).flip().enhance().store()

filelink = Filelink("<YOUR_HANDLE">)
new_filelink = filelink.resize(width=500, height=500).flip().enhance().store()
```

You can also retrieve the transformation url at any point.

```python
transform_candidate = client.transform_external('http://<SOME_URL>')
transform = transform_candidate.resize(width=500, height=500).flip().enhance()
print(transform.url)
```

### Audio/Video Convert

Audio and video conversion works just like any transformation, except it returns an instance of class AudioVisual, which allows you to check the status of your video conversion, as well as get its UUID and timestamp.

```python
av_object = filelink.av_convert(width=100, height=100)
while (av_object.status != 'completed'):
print(av_object.status)
print(av_object.uuid)
print(av_object.timestamp)
```

The status property makes a call to the API to check its current status, and you can call to_filelink() once video is complete (this function checks its status first and will fail if not completed yet).

```python
filelink = av_object.to_filelink()
```

### Security Objects

Security is set on Client or Filelink classes upon instantiation.

```python
from filestack import security

json_policy = {"expiry": 253381964415}
security = security(json_policy, '<YOUR_APP_SECRET>')
client = Client("<YOUR_API_KEY", security=security)

# new Filelink object inherits security and will use for all calls
new_filelink = client.upload(filepath="path/to/file")
```

## Versioning

Filestack Python SDK follows the [Semantic Versioning](http://semver.org/).


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

filestack-python-2.4.0.tar.gz (22.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

filestack_python-2.4.0-py3-none-any.whl (35.4 kB view details)

Uploaded Python 3

File details

Details for the file filestack-python-2.4.0.tar.gz.

File metadata

  • Download URL: filestack-python-2.4.0.tar.gz
  • Upload date:
  • Size: 22.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

File hashes

Hashes for filestack-python-2.4.0.tar.gz
Algorithm Hash digest
SHA256 db51ac13a7453f4200b98d65d34e51b43e8ff46c3f610eb85e083918451908cc
MD5 8a0806f10e9da9c9a92113e06e4df255
BLAKE2b-256 7a60380a1b0c756bce363bf14e7b78b87481df96d66c92368dd5c65a49b7dab1

See more details on using hashes here.

File details

Details for the file filestack_python-2.4.0-py3-none-any.whl.

File metadata

  • Download URL: filestack_python-2.4.0-py3-none-any.whl
  • Upload date:
  • Size: 35.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.0

File hashes

Hashes for filestack_python-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 35ff2a653d80d19eeec47649261cb23e1c77d3bf2d0de45fa2f9eb398a75341e
MD5 941584833b67c721b532bf55f1496566
BLAKE2b-256 780b0daa88ce7ca94ec514f7ead286db2a07d6cde71ddb4eaeaee58b041dfe19

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page