-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsample.py
More file actions
43 lines (37 loc) · 958 Bytes
/
sample.py
File metadata and controls
43 lines (37 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import asyncio
from pixelbin import PixelbinClient, PixelbinConfig
from pixelbin.utils import security
config = PixelbinConfig(
{
"domain": "https://api.pixelbin.io",
"apiSecret": "API_TOKEN",
}
)
pixelbin = PixelbinClient(config)
# Sync method call
try:
result = pixelbin.assets.fileUpload(file=open("./tests/1.jpeg", "rb"))
# use result
print(result)
except Exception as e:
print(e)
# Async method call
try:
result = asyncio.get_event_loop().run_until_complete(
pixelbin.assets.fileUpload(file=open("./tests/1.jpeg", "rb"))
)
# use result
print(result)
except Exception as e:
print(e)
# Generate signed urls
try:
signed_url = security.sign_url(
"https://test.example.com/v2/original/__playground/playground-default.jpeg",
600,
"c1adc3ba-75b6-492c-bfb4-e879f2ae61fe",
"dummy-token",
)
print(signed_url)
except Exception as e:
print(e)