Skip to content

Commit

Permalink
Merge pull request #69 from imagekit-developer/IK-1499
Browse files Browse the repository at this point in the history
IK-1499 added checks parameter
  • Loading branch information
ahnv authored Sep 5, 2024
2 parents 43f8922 + 120e828 commit cc951b2
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 4 deletions.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ options = UploadFileRequestOptions(
overwrite_tags=False,
overwrite_custom_metadata=True,
custom_metadata={'testss': 12},
transformation=transformation
transformation=transformation,
checks="'request.folder' : '/testing-python-folder'", # To run server side checks before uploading files. Notice the quotes around request.folder and /testing-python-folder.
is_published=True
)

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

**Update publish status**

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`.

```python
from imagekitio.models.UpdateFileRequestOptions import UpdateFileRequestOptions

options = UpdateFileRequestOptions(
publish={
"isPublished": True,
"includeFileVersions": True
}
)

result = imagekit.update_file_details(file_id='62cfd39819ca454d82a07182'
, options=options) # required

# Final Result
print(result)

# Raw Response
print(result.response_metadata.raw)

# print that file's id
print(result.file_id)
```

**6. Add tags**

Accepts a list of `file_ids` and `tags` as a parameter to be used to add tags. All parameters specified in
Expand Down
2 changes: 2 additions & 0 deletions imagekitio/constants/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@
"custom_metadata",
"embedded_metadata",
"transformation",
"checks",
"is_published",
]
3 changes: 3 additions & 0 deletions imagekitio/models/UpdateFileRequestOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ def __init__(
tags: List[str] = None,
custom_coordinates: str = None,
custom_metadata: json = None,
publish: json = None,
):
if publish is not None:
self.publish = publish
if remove_ai_tags is not None:
self.remove_ai_tags = remove_ai_tags
if webhook_url is not None:
Expand Down
6 changes: 6 additions & 0 deletions imagekitio/models/UploadFileRequestOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def __init__(
overwrite_custom_metadata: bool = None,
custom_metadata: json = None,
transformation: json = None,
checks: str = None,
is_published: bool = None,
):
if use_unique_file_name is not None:
self.use_unique_file_name = use_unique_file_name
Expand Down Expand Up @@ -48,3 +50,7 @@ def __init__(
self.custom_metadata = custom_metadata
if transformation is not None:
self.transformation = transformation
if checks is not None:
self.checks = checks
if is_published is not None:
self.is_published = is_published
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setuptools.setup(
name="imagekitio",
version="4.0.1",
version="4.1.0",
description="Python wrapper for the ImageKit API",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
145 changes: 143 additions & 2 deletions tests/test_files_ops.py

Large diffs are not rendered by default.

0 comments on commit cc951b2

Please sign in to comment.