2
2
3
3
from __future__ import annotations
4
4
5
- from typing import Dict , List , Mapping , Iterable , cast
5
+ from typing import Dict , List , Iterable
6
6
from typing_extensions import Literal
7
7
8
8
import httpx
16
16
AsyncBulkResourceWithStreamingResponse ,
17
17
)
18
18
from ...types import file_copy_params , file_move_params , file_rename_params , file_update_params , file_upload_params
19
- from ..._types import NOT_GIVEN , Body , Query , Headers , NoneType , NotGiven , FileTypes
20
- from ..._utils import extract_files , maybe_transform , deepcopy_minimal , async_maybe_transform
19
+ from ..._types import NOT_GIVEN , Body , Query , Headers , NoneType , NotGiven
20
+ from ..._utils import maybe_transform , async_maybe_transform
21
21
from .metadata import (
22
22
MetadataResource ,
23
23
AsyncMetadataResource ,
@@ -368,7 +368,7 @@ def rename(
368
368
def upload (
369
369
self ,
370
370
* ,
371
- file : FileTypes ,
371
+ file : str ,
372
372
file_name : str ,
373
373
token : str | NotGiven = NOT_GIVEN ,
374
374
checks : str | NotGiven = NOT_GIVEN ,
@@ -579,34 +579,6 @@ def upload(
579
579
580
580
timeout: Override the client-level default timeout for this request, in seconds
581
581
"""
582
- body = deepcopy_minimal (
583
- {
584
- "file" : file ,
585
- "file_name" : file_name ,
586
- "token" : token ,
587
- "checks" : checks ,
588
- "custom_coordinates" : custom_coordinates ,
589
- "custom_metadata" : custom_metadata ,
590
- "description" : description ,
591
- "expire" : expire ,
592
- "extensions" : extensions ,
593
- "folder" : folder ,
594
- "is_private_file" : is_private_file ,
595
- "is_published" : is_published ,
596
- "overwrite_ai_tags" : overwrite_ai_tags ,
597
- "overwrite_custom_metadata" : overwrite_custom_metadata ,
598
- "overwrite_file" : overwrite_file ,
599
- "overwrite_tags" : overwrite_tags ,
600
- "public_key" : public_key ,
601
- "response_fields" : response_fields ,
602
- "signature" : signature ,
603
- "tags" : tags ,
604
- "transformation" : transformation ,
605
- "use_unique_file_name" : use_unique_file_name ,
606
- "webhook_url" : webhook_url ,
607
- }
608
- )
609
- files = extract_files (cast (Mapping [str , object ], body ), paths = [["file" ]])
610
582
# It should be noted that the actual Content-Type header that will be
611
583
# sent to the server will contain a `boundary` parameter, e.g.
612
584
# multipart/form-data; boundary=---abc--
@@ -615,8 +587,34 @@ def upload(
615
587
"/api/v1/files/upload"
616
588
if self ._client ._base_url_overridden
617
589
else "https://upload.imagekit.io/api/v1/files/upload" ,
618
- body = maybe_transform (body , file_upload_params .FileUploadParams ),
619
- files = files ,
590
+ body = maybe_transform (
591
+ {
592
+ "file" : file ,
593
+ "file_name" : file_name ,
594
+ "token" : token ,
595
+ "checks" : checks ,
596
+ "custom_coordinates" : custom_coordinates ,
597
+ "custom_metadata" : custom_metadata ,
598
+ "description" : description ,
599
+ "expire" : expire ,
600
+ "extensions" : extensions ,
601
+ "folder" : folder ,
602
+ "is_private_file" : is_private_file ,
603
+ "is_published" : is_published ,
604
+ "overwrite_ai_tags" : overwrite_ai_tags ,
605
+ "overwrite_custom_metadata" : overwrite_custom_metadata ,
606
+ "overwrite_file" : overwrite_file ,
607
+ "overwrite_tags" : overwrite_tags ,
608
+ "public_key" : public_key ,
609
+ "response_fields" : response_fields ,
610
+ "signature" : signature ,
611
+ "tags" : tags ,
612
+ "transformation" : transformation ,
613
+ "use_unique_file_name" : use_unique_file_name ,
614
+ "webhook_url" : webhook_url ,
615
+ },
616
+ file_upload_params .FileUploadParams ,
617
+ ),
620
618
options = make_request_options (
621
619
extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
622
620
),
@@ -939,7 +937,7 @@ async def rename(
939
937
async def upload (
940
938
self ,
941
939
* ,
942
- file : FileTypes ,
940
+ file : str ,
943
941
file_name : str ,
944
942
token : str | NotGiven = NOT_GIVEN ,
945
943
checks : str | NotGiven = NOT_GIVEN ,
@@ -1150,34 +1148,6 @@ async def upload(
1150
1148
1151
1149
timeout: Override the client-level default timeout for this request, in seconds
1152
1150
"""
1153
- body = deepcopy_minimal (
1154
- {
1155
- "file" : file ,
1156
- "file_name" : file_name ,
1157
- "token" : token ,
1158
- "checks" : checks ,
1159
- "custom_coordinates" : custom_coordinates ,
1160
- "custom_metadata" : custom_metadata ,
1161
- "description" : description ,
1162
- "expire" : expire ,
1163
- "extensions" : extensions ,
1164
- "folder" : folder ,
1165
- "is_private_file" : is_private_file ,
1166
- "is_published" : is_published ,
1167
- "overwrite_ai_tags" : overwrite_ai_tags ,
1168
- "overwrite_custom_metadata" : overwrite_custom_metadata ,
1169
- "overwrite_file" : overwrite_file ,
1170
- "overwrite_tags" : overwrite_tags ,
1171
- "public_key" : public_key ,
1172
- "response_fields" : response_fields ,
1173
- "signature" : signature ,
1174
- "tags" : tags ,
1175
- "transformation" : transformation ,
1176
- "use_unique_file_name" : use_unique_file_name ,
1177
- "webhook_url" : webhook_url ,
1178
- }
1179
- )
1180
- files = extract_files (cast (Mapping [str , object ], body ), paths = [["file" ]])
1181
1151
# It should be noted that the actual Content-Type header that will be
1182
1152
# sent to the server will contain a `boundary` parameter, e.g.
1183
1153
# multipart/form-data; boundary=---abc--
@@ -1186,8 +1156,34 @@ async def upload(
1186
1156
"/api/v1/files/upload"
1187
1157
if self ._client ._base_url_overridden
1188
1158
else "https://upload.imagekit.io/api/v1/files/upload" ,
1189
- body = await async_maybe_transform (body , file_upload_params .FileUploadParams ),
1190
- files = files ,
1159
+ body = await async_maybe_transform (
1160
+ {
1161
+ "file" : file ,
1162
+ "file_name" : file_name ,
1163
+ "token" : token ,
1164
+ "checks" : checks ,
1165
+ "custom_coordinates" : custom_coordinates ,
1166
+ "custom_metadata" : custom_metadata ,
1167
+ "description" : description ,
1168
+ "expire" : expire ,
1169
+ "extensions" : extensions ,
1170
+ "folder" : folder ,
1171
+ "is_private_file" : is_private_file ,
1172
+ "is_published" : is_published ,
1173
+ "overwrite_ai_tags" : overwrite_ai_tags ,
1174
+ "overwrite_custom_metadata" : overwrite_custom_metadata ,
1175
+ "overwrite_file" : overwrite_file ,
1176
+ "overwrite_tags" : overwrite_tags ,
1177
+ "public_key" : public_key ,
1178
+ "response_fields" : response_fields ,
1179
+ "signature" : signature ,
1180
+ "tags" : tags ,
1181
+ "transformation" : transformation ,
1182
+ "use_unique_file_name" : use_unique_file_name ,
1183
+ "webhook_url" : webhook_url ,
1184
+ },
1185
+ file_upload_params .FileUploadParams ,
1186
+ ),
1191
1187
options = make_request_options (
1192
1188
extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
1193
1189
),
0 commit comments