Skip to content

Commit 651496b

Browse files
ANKUR DWIVEDIANKUR DWIVEDI
authored andcommitted
added publish
1 parent be6567d commit 651496b

File tree

4 files changed

+50
-14
lines changed

4 files changed

+50
-14
lines changed

README.md

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,9 @@ options = UploadFileRequestOptions(
421421
overwrite_tags=False,
422422
overwrite_custom_metadata=True,
423423
custom_metadata={'testss': 12},
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.
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+
isPublished=True
426427
)
427428

428429
result = imagekit.upload_file(file='<url|base_64|binary>', # required
@@ -622,6 +623,33 @@ print(result.response_metadata.raw)
622623
print(result.file_id)
623624
```
624625

626+
**Update publish status**
627+
628+
If `UpdateFileRequestOptions` contains the `publish` property, all other properties will be ignored.
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+
625653
**6. Add tags**
626654

627655
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@
3131
"embedded_metadata",
3232
"transformation",
3333
"checks",
34+
"isPublished",
3435
]

imagekitio/models/UpdateFileRequestOptions.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@ def __init__(
1111
tags: List[str] = None,
1212
custom_coordinates: str = None,
1313
custom_metadata: json = None,
14+
publish: json = None,
1415
):
15-
if remove_ai_tags is not None:
16-
self.remove_ai_tags = remove_ai_tags
17-
if webhook_url is not None:
18-
self.webhook_url = webhook_url
19-
if extensions is not None:
20-
self.extensions = extensions
21-
if tags is not None:
22-
self.tags = tags
23-
if custom_coordinates is not None:
24-
self.custom_coordinates = custom_coordinates
25-
if custom_metadata is not None:
26-
self.custom_metadata = custom_metadata
16+
if publish is not None:
17+
self.publish = publish
18+
else:
19+
if remove_ai_tags is not None:
20+
self.remove_ai_tags = remove_ai_tags
21+
if webhook_url is not None:
22+
self.webhook_url = webhook_url
23+
if extensions is not None:
24+
self.extensions = extensions
25+
if tags is not None:
26+
self.tags = tags
27+
if custom_coordinates is not None:
28+
self.custom_coordinates = custom_coordinates
29+
if custom_metadata is not None:
30+
self.custom_metadata = custom_metadata

imagekitio/models/UploadFileRequestOptions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def __init__(
2020
custom_metadata: json = None,
2121
transformation: json = None,
2222
checks: str = None,
23+
isPublished: bool = None,
2324
):
2425
if use_unique_file_name is not None:
2526
self.use_unique_file_name = use_unique_file_name
@@ -51,3 +52,5 @@ def __init__(
5152
self.transformation = transformation
5253
if checks is not None:
5354
self.checks = checks
55+
if isPublished is not None:
56+
self.isPublished = isPublished

0 commit comments

Comments
 (0)