Skip to content

Commit cc951b2

Browse files
authored
Merge pull request #69 from imagekit-developer/IK-1499
IK-1499 added checks parameter
2 parents 43f8922 + 120e828 commit cc951b2

File tree

6 files changed

+185
-4
lines changed

6 files changed

+185
-4
lines changed

README.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,9 @@ options = UploadFileRequestOptions(
421421
overwrite_tags=False,
422422
overwrite_custom_metadata=True,
423423
custom_metadata={'testss': 12},
424-
transformation=transformation
424+
transformation=transformation,
425+
checks="'request.folder' : '/testing-python-folder'", # To run server side checks before uploading files. Notice the quotes around request.folder and /testing-python-folder.
426+
is_published=True
425427
)
426428

427429
result = imagekit.upload_file(file='<url|base_64|binary>', # required
@@ -621,6 +623,33 @@ print(result.response_metadata.raw)
621623
print(result.file_id)
622624
```
623625

626+
**Update publish status**
627+
628+
If `publish` is included in the update options, no other parameters are allowed. If any are present, an error will be returned: `Your request cannot contain any other parameters when publish is present`.
629+
630+
```python
631+
from imagekitio.models.UpdateFileRequestOptions import UpdateFileRequestOptions
632+
633+
options = UpdateFileRequestOptions(
634+
publish={
635+
"isPublished": True,
636+
"includeFileVersions": True
637+
}
638+
)
639+
640+
result = imagekit.update_file_details(file_id='62cfd39819ca454d82a07182'
641+
, options=options) # required
642+
643+
# Final Result
644+
print(result)
645+
646+
# Raw Response
647+
print(result.response_metadata.raw)
648+
649+
# print that file's id
650+
print(result.file_id)
651+
```
652+
624653
**6. Add tags**
625654

626655
Accepts a list of `file_ids` and `tags` as a parameter to be used to add tags. All parameters specified in

imagekitio/constants/files.py

+2
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,6 @@
3030
"custom_metadata",
3131
"embedded_metadata",
3232
"transformation",
33+
"checks",
34+
"is_published",
3335
]

imagekitio/models/UpdateFileRequestOptions.py

+3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ def __init__(
1111
tags: List[str] = None,
1212
custom_coordinates: str = None,
1313
custom_metadata: json = None,
14+
publish: json = None,
1415
):
16+
if publish is not None:
17+
self.publish = publish
1518
if remove_ai_tags is not None:
1619
self.remove_ai_tags = remove_ai_tags
1720
if webhook_url is not None:

imagekitio/models/UploadFileRequestOptions.py

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ def __init__(
1919
overwrite_custom_metadata: bool = None,
2020
custom_metadata: json = None,
2121
transformation: json = None,
22+
checks: str = None,
23+
is_published: bool = None,
2224
):
2325
if use_unique_file_name is not None:
2426
self.use_unique_file_name = use_unique_file_name
@@ -48,3 +50,7 @@ def __init__(
4850
self.custom_metadata = custom_metadata
4951
if transformation is not None:
5052
self.transformation = transformation
53+
if checks is not None:
54+
self.checks = checks
55+
if is_published is not None:
56+
self.is_published = is_published

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
setuptools.setup(
1010
name="imagekitio",
11-
version="4.0.1",
11+
version="4.1.0",
1212
description="Python wrapper for the ImageKit API",
1313
long_description=long_description,
1414
long_description_content_type="text/markdown",

tests/test_files_ops.py

+143-2
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)