Skip to content

Commit 39c5e15

Browse files
author
bkwi
authored
Merge pull request #50 from filestack/feature/FS-7434-upload-tags
FS-7434 upload tags
2 parents 57091bd + 1afa0e0 commit 39c5e15

File tree

7 files changed

+41
-22
lines changed

7 files changed

+41
-22
lines changed

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Sphinx==2.1.2
22
sphinx-rtd-theme==0.4.3
3-
trafaret==1.2.0
4-
requests==2.22.0
3+
trafaret==2.0.2
4+
requests==2.23.0

docs/source/uploading_files.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,20 @@ Each upload function shown above takes a :data:`store_params` argument which is
7979
'region': 'string',
8080
'access': 'string',
8181
'base64decode': True|False,
82-
'workflows': ['workflow-id-1', 'workflow-id-2']
82+
'workflows': ['workflow-id-1', 'workflow-id-2'],
83+
'upload_tags': {
84+
'key': 'value',
85+
'key2': 'value'
86+
}
8387
}
8488
8589
* **filename** - name for the stored file
86-
* **location** - name for the stored file
90+
* **location** - storage provider to be used
8791
* **path** - the path to store the file within the specified container
8892
* **container** - the bucket or container (folder) in which to store the file (does not apply when storing to Dropbox)
8993
* **mimetype** - mime type that should be stored in file's metadata
9094
* **region** - storage region (applies to S3 only)
9195
* **access** - should the file be stored as :data:`"public"` or :data:`"private"` (applies to S3 only)
9296
* **base64decode** - indicates if content should be decoded before it is stored
9397
* **workflows** - IDs of `Filestack Workflows <https://www.filestack.com/products/workflows>`_ that should be triggered after upload
98+
* **upload_tags** - set of :data:`key: value` pairs that will be returned with webhook for particular upload

filestack/models/security.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ def as_url_string(self):
3535
Returns the security part of signed urls
3636
3737
Returns:
38-
str: url part in the form of :data:`security=p:\<encoded policy>,s:\<signature>`
38+
str: url part in the form of :data:`security=p:\\<encoded policy>,s:\\<signature>`
3939
"""
4040
return 'security=p:{},s:{}'.format(self.policy_b64, self.signature)

filestack/trafarets.py

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@
22

33
STORE_LOCATION_SCHEMA = t.Enum('S3', 'gcs', 'azure', 'rackspace', 'dropbox')
44

5-
STORE_SCHEMA = t.Dict({
6-
'filename': t.String(),
7-
'mimetype': t.String(),
8-
'location': t.String(),
9-
'path': t.String(),
10-
'container': t.String(),
11-
'region': t.String(),
12-
'access': t.String(),
13-
'base64decode': t.Bool(),
14-
'workflows': t.List(t.String())
15-
}).make_optional('*')
5+
6+
def validate_upload_tags(d):
7+
t.List(t.String, max_length=10).check(list(d.keys()))
8+
t.Mapping(t.String(max_length=128), t.String(max_length=256)).check(d)
9+
return d
10+
11+
12+
STORE_SCHEMA = t.Dict(
13+
t.Key('filename', optional=True, trafaret=t.String),
14+
t.Key('mimetype', optional=True, trafaret=t.String),
15+
t.Key('location', optional=True, trafaret=t.String),
16+
t.Key('path', optional=True, trafaret=t.String),
17+
t.Key('container', optional=True, trafaret=t.String),
18+
t.Key('region', optional=True, trafaret=t.String),
19+
t.Key('access', optional=True, trafaret=t.String),
20+
t.Key('base64decode', optional=True, trafaret=t.Bool),
21+
t.Key('workflows', optional=True, trafaret=t.List(t.String)),
22+
t.Key('upload_tags', optional=True, trafaret=validate_upload_tags),
23+
)

filestack/uploads/intelligent_ingestion.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,11 @@ def upload(apikey, filepath, file_obj, storage, params=None, security=None):
139139
'upload_id': start_response['upload_id'],
140140
})
141141

142-
if params.get('workflows'):
143-
payload['store']['workflows'] = params['workflows']
142+
if 'workflows' in params:
143+
payload['store']['workflows'] = params.pop('workflows')
144+
145+
if 'upload_tags' in params:
146+
payload['upload_tags'] = params.pop('upload_tags')
144147

145148
complete_url = 'https://{}/multipart/complete'.format(start_response['location_url'])
146149
session = requests.Session()

filestack/uploads/multipart.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,11 @@ def multipart_upload(apikey, filepath, file_obj, storage, params=None, security=
121121
payload.update(start_response)
122122
payload['parts'] = uploaded_parts
123123

124-
if params.get('workflows'):
125-
payload['store']['workflows'] = params['workflows']
124+
if 'workflows' in params:
125+
payload['store']['workflows'] = params.pop('workflows')
126+
127+
if 'upload_tags' in params:
128+
payload['upload_tags'] = params.pop('upload_tags')
126129

127130
complete_url = 'https://{}/multipart/complete'.format(location_url)
128131
complete_response = multipart_request(complete_url, payload, params, security)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ def read_version():
2323
author_email='support@filestack.com',
2424
packages=find_packages(),
2525
install_requires=[
26-
'requests==2.22.0',
27-
'trafaret==1.2.0'
26+
'requests==2.23.0',
27+
'trafaret==2.0.2'
2828
],
2929
classifiers=[
3030
'Development Status :: 4 - Beta',

0 commit comments

Comments
 (0)