Esempio n. 1
0
from filestack import Client, security

# expires in 2099 ;)
policy = {'expiry': 4085665557}
app_secret = '<YOUR_APP_SECRET>'
sec = security(policy, app_secret)

client = Client('<YOUR_API_KEY>', security=sec)
filelink = client.upload(
    url='http://weknownyourdreamz.com/images/birds/birds-04.jpg')

tags = filelink.tags()
sfw = filelink.sfw()
print(tags)
print(sfw)
from base64 import b64encode
from filestack import Filelink, security
from filestack.config import CDN_URL
from httmock import urlmatch, HTTMock, response
from trafaret import DataError

APIKEY = 'APIKEY'
HANDLE = 'SOMEHANDLE'


@pytest.fixture
def filelink():
    return Filelink(HANDLE, apikey=APIKEY)


SECURITY = security({'call': ['read'], 'expiry': 10238239}, 'APPSECRET')


@pytest.fixture
def secure_filelink():
    return Filelink(HANDLE, apikey=APIKEY, security=SECURITY)


def test_handle(filelink):
    assert filelink.handle == HANDLE


def test_apikey_default():
    filelink_default = Filelink(HANDLE)
    assert filelink_default.apikey is None
def test_correct_encoding():
    policy = security(GOOD_POLICY, SECRET)
    assert b64decode(
        policy['policy']).decode('utf-8') == json.dumps(GOOD_POLICY)
def test_good_policy_json():
    policy = security(GOOD_POLICY, SECRET)
    assert policy['policy']
    assert policy['signature']
from filestack import Client, security

# policy expires on 5/6/2099
policy = {'call': ['read', 'remove', 'store'], 'expiry': 4081759876}
security = security(policy, '<YOUR_APP_SECRET>')

client = Client(apikey='<YOUR_API_KEY>', security=security)
filelink = client.upload(
    url=
    'https://www.wbu.com/wp-content/uploads/2016/07/540x340-found-a-bird-450x283.jpg'
)

delete_response = filelink.delete()
Esempio n. 6
0
from filestack import Client, security

# policy expires on 5/6/2099
json_policy = {'call': ['read', 'remove', 'store'], 'expiry': 4081759876}

security = security(json_policy, '<YOUR_APP_SECRET>')

client = Client('<YOUR_API_KEY>', security=security)

transform = client.transform_external(
    'https://images.unsplash.com/photo-1446776877081-d282a0f896e2?dpr=1&auto=format&fit=crop&w=1500&h=998&q=80&cs=tinysrgb&crop=&bg='
)
transform.blackwhite(threshold=50).flip()

print(transform.get_transformation_url())