-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add some transformation functions for the ticket FS-7947 and FS-6057 * Add some transformation functions for the ticket FS-7947 and FS-6057 * Add some transformation functions for the ticket FS-7947 and FS-6057
- Loading branch information
1 parent
cb0c3d5
commit cf123d3
Showing
8 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from filestack import Client, Security | ||
|
||
# create security object | ||
json_policy = {"expiry":1717101000,"call":["pick","read","stat","write","writeUrl","store","convert"]} | ||
security = Security(json_policy, '<YOUR_APP_SECRET>') | ||
APIKEY = '<YOUR_API_KEY>' | ||
|
||
client = Client(apikey=APIKEY, security=security) | ||
transform = client.transform_external('/animate=fit:scale,width:200,height:300/[<HANDLER1>,<HANDLER2>]') | ||
transform.animate(fit='scale',width=200,height=300,loop=0,delay=1000) | ||
print(transform.url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from filestack import Client, Security | ||
|
||
# create security object | ||
json_policy = {"call":["pick","read","stat","write","writeUrl","store","convert"],"expiry":1717099200} | ||
security = Security(json_policy, '<YOUR_APP_SECRET>') | ||
APIKEY = '<YOUR_API_KEY>' | ||
|
||
client = Client(apikey=APIKEY, security=security) | ||
transform = client.transform_external('pdfconvert=pageorientation:landscape/HANDLER') | ||
transform.pdf_convert(pageorientation='landscape', pageformat='a4', metadata=True) | ||
print(transform.url) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from filestack import Client, Security | ||
|
||
# create security object | ||
json_policy = {"call":["pick","read","stat","write","writeUrl","store","convert"],"expiry":1717099200} | ||
security = Security(json_policy, '<YOUR_APP_SECRET>') | ||
APIKEY = '<YOUR_API_KEY>' | ||
|
||
client = Client(apikey=APIKEY, security=security) | ||
transform = client.transform_external('/pdfcreate/[<HANDLER1>,<HANDLER2>]') | ||
transform.pdfcreate(engine='mupdf') | ||
print(transform.url) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from filestack import Client, Security | ||
|
||
# create security object | ||
json_policy = {"call":["pick","read","stat","write","writeUrl","store","convert"],"expiry":1717099200} | ||
security = Security(json_policy, '<YOUR_APP_SECRET>') | ||
APIKEY = '<YOUR_API_KEY>' | ||
|
||
client = Client(apikey=APIKEY, security=security) | ||
transform = client.transform_external('/doc_to_images/<HANDLE>') | ||
transform.doc_to_images(pages=[1], engine='imagemagick', format='png', quality=100, density=100, hidden_slides=False) | ||
print(transform.url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from filestack import Client, Security | ||
|
||
# create security object | ||
json_policy = {"call":["pick","read","stat","write","writeUrl","store","convert"],"expiry":1717099200} | ||
security = Security(json_policy, '<YOUR_APP_SECRET>') | ||
APIKEY = '<YOUR_API_KEY>' | ||
|
||
client = Client(apikey=APIKEY, security=security) | ||
transform = client.transform_external('/') | ||
transform.fallback(file='HANDLER', cache=12) | ||
print(transform.url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from filestack import Client, Security | ||
|
||
# create security object | ||
json_policy = {"call":["pick","read","stat","write","writeUrl","store","convert"],"expiry":1717099200} | ||
security = Security(json_policy, '<YOUR_APP_SECRET>') | ||
APIKEY = '<YOUR_API_KEY>' | ||
|
||
client = Client(apikey=APIKEY, security=security) | ||
transform = client.transform_external('/smart_crop=width:100,height:100/HANDLER') | ||
transform.smart_crop(width=100, height=100) | ||
print(transform.url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import re | ||
|
||
import pytest | ||
import responses | ||
|
||
from filestack import Transformation, AudioVisual | ||
from filestack import config | ||
|
||
APIKEY = 'SOMEAPIKEY' | ||
HANDLE = 'SOMEHANDLE' | ||
EXTERNAL_URL = 'SOMEEXTERNALURL' | ||
|
||
|
||
@pytest.fixture | ||
def transform(): | ||
return Transformation(apikey=APIKEY, external_url=EXTERNAL_URL) | ||
|
||
|
||
def test_createpdf(transform): | ||
target_url = '{}/{}/pdfcreate/{}/[v7MSSKswR0mvEwZS9LD0,Sr5CrtQPSs5TTZzor1Cw]'.format(config.CDN_URL, APIKEY, EXTERNAL_URL) | ||
obj = transform.pdfcreate(engine='mupdf') | ||
assert obj.url | ||
|
||
def test_animate(transform): | ||
target_url = '{}/{}/animate=fit:scale,width:200,height:300/{}/[OjKeBAuBTIWygi1NE8fx,WTY6jjIaTPOvWY9KsNh9]'.format(config.CDN_URL, APIKEY, EXTERNAL_URL) | ||
obj = transform.animate(fit='scale',width=200,height=300,loop=0,delay=1000) | ||
assert obj.url | ||
|
||
def test_doc_to_images(transform): | ||
target_url = '{}/{}/doc_to_images/{}/3zOWSOLQ0SEdphqVil9Q'.format(config.CDN_URL, APIKEY, EXTERNAL_URL) | ||
obj = transform.doc_to_images(pages=[1], engine='imagemagick', format='png', quality=100, density=100, hidden_slides=False) | ||
assert obj.url | ||
|
||
def test_smart_crop(transform): | ||
target_url = '{}/{}/smart_crop=width:100,height:100/{}/v7MSSKswR0mvEwZS9LD0'.format(config.CDN_URL, APIKEY, EXTERNAL_URL) | ||
obj = transform.smart_crop(width=100, height=100) | ||
assert obj.url | ||
|
||
def test_pdf_convert(transform): | ||
target_url = '{}/{}/pdfconvert=pageorientation:landscape/{}/3zOWSOLQ0SEdphqVil9Q'.format(config.CDN_URL, APIKEY, EXTERNAL_URL) | ||
obj = transform.pdf_convert(pageorientation='landscape', pageformat='a4', metadata=True) | ||
assert obj.url | ||
|
||
def test_fallback(transform): | ||
target_url = '{}/{}/{}'.format(config.CDN_URL, APIKEY, EXTERNAL_URL) | ||
obj = transform.fallback(file='3zOWSOLQ0SEdphqVil9Q', cache=12) | ||
assert obj.url |