@@ -28,13 +28,9 @@ import com.imagekit.api.core.http.Headers
28
28
import com.imagekit.api.core.http.QueryParams
29
29
import com.imagekit.api.core.toImmutable
30
30
import com.imagekit.api.errors.ImageKitInvalidDataException
31
- import java.io.InputStream
32
- import java.nio.file.Path
33
31
import java.util.Collections
34
32
import java.util.Objects
35
33
import java.util.Optional
36
- import kotlin.io.path.inputStream
37
- import kotlin.io.path.name
38
34
import kotlin.jvm.optionals.getOrNull
39
35
40
36
/* *
@@ -78,7 +74,7 @@ private constructor(
78
74
* @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is
79
75
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
80
76
*/
81
- fun file (): InputStream = body.file()
77
+ fun file (): String = body.file()
82
78
83
79
/* *
84
80
* The name with which the file has to be uploaded. The file name can contain:
@@ -327,7 +323,7 @@ private constructor(
327
323
*
328
324
* Unlike [file], this method doesn't throw if the multipart field has an unexpected type.
329
325
*/
330
- fun _file (): MultipartField <InputStream > = body._file ()
326
+ fun _file (): MultipartField <String > = body._file ()
331
327
332
328
/* *
333
329
* Returns the raw multipart value of [fileName].
@@ -556,38 +552,15 @@ private constructor(
556
552
* When supplying a URL, the server must receive the response headers within 8 seconds;
557
553
* otherwise the request fails with 400 Bad Request.
558
554
*/
559
- fun file (file : InputStream ) = apply { body.file(file) }
555
+ fun file (file : String ) = apply { body.file(file) }
560
556
561
557
/* *
562
558
* Sets [Builder.file] to an arbitrary multipart value.
563
559
*
564
- * You should usually call [Builder.file] with a well-typed [InputStream] value instead.
565
- * This method is primarily for setting the field to an undocumented or not yet supported
566
- * value.
567
- */
568
- fun file (file : MultipartField <InputStream >) = apply { body.file(file) }
569
-
570
- /* *
571
- * The API accepts any of the following:
572
- * - **Binary data** – send the raw bytes as `multipart/form-data`.
573
- * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.
574
- * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64.
575
- *
576
- * When supplying a URL, the server must receive the response headers within 8 seconds;
577
- * otherwise the request fails with 400 Bad Request.
578
- */
579
- fun file (file : ByteArray ) = apply { body.file(file) }
580
-
581
- /* *
582
- * The API accepts any of the following:
583
- * - **Binary data** – send the raw bytes as `multipart/form-data`.
584
- * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.
585
- * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64.
586
- *
587
- * When supplying a URL, the server must receive the response headers within 8 seconds;
588
- * otherwise the request fails with 400 Bad Request.
560
+ * You should usually call [Builder.file] with a well-typed [String] value instead. This
561
+ * method is primarily for setting the field to an undocumented or not yet supported value.
589
562
*/
590
- fun file (path : Path ) = apply { body.file(path ) }
563
+ fun file (file : MultipartField < String > ) = apply { body.file(file ) }
591
564
592
565
/* *
593
566
* The name with which the file has to be uploaded. The file name can contain:
@@ -1197,7 +1170,7 @@ private constructor(
1197
1170
1198
1171
class Body
1199
1172
private constructor (
1200
- private val file: MultipartField <InputStream >,
1173
+ private val file: MultipartField <String >,
1201
1174
private val fileName: MultipartField <String >,
1202
1175
private val token: MultipartField <String >,
1203
1176
private val checks: MultipartField <String >,
@@ -1235,7 +1208,7 @@ private constructor(
1235
1208
* @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is
1236
1209
* unexpectedly missing or null (e.g. if the server responded with an unexpected value).
1237
1210
*/
1238
- fun file (): InputStream = file.value.getRequired(" file" )
1211
+ fun file (): String = file.value.getRequired(" file" )
1239
1212
1240
1213
/* *
1241
1214
* The name with which the file has to be uploaded. The file name can contain:
@@ -1492,7 +1465,7 @@ private constructor(
1492
1465
*
1493
1466
* Unlike [file], this method doesn't throw if the multipart field has an unexpected type.
1494
1467
*/
1495
- @JsonProperty(" file" ) @ExcludeMissing fun _file (): MultipartField <InputStream > = file
1468
+ @JsonProperty(" file" ) @ExcludeMissing fun _file (): MultipartField <String > = file
1496
1469
1497
1470
/* *
1498
1471
* Returns the raw multipart value of [fileName].
@@ -1726,7 +1699,7 @@ private constructor(
1726
1699
/* * A builder for [Body]. */
1727
1700
class Builder internal constructor() {
1728
1701
1729
- private var file: MultipartField <InputStream >? = null
1702
+ private var file: MultipartField <String >? = null
1730
1703
private var fileName: MultipartField <String >? = null
1731
1704
private var token: MultipartField <String > = MultipartField .of(null )
1732
1705
private var checks: MultipartField <String > = MultipartField .of(null )
@@ -1788,44 +1761,16 @@ private constructor(
1788
1761
* When supplying a URL, the server must receive the response headers within 8 seconds;
1789
1762
* otherwise the request fails with 400 Bad Request.
1790
1763
*/
1791
- fun file (file : InputStream ) = file(MultipartField .of(file))
1764
+ fun file (file : String ) = file(MultipartField .of(file))
1792
1765
1793
1766
/* *
1794
1767
* Sets [Builder.file] to an arbitrary multipart value.
1795
1768
*
1796
- * You should usually call [Builder.file] with a well-typed [InputStream] value instead.
1797
- * This method is primarily for setting the field to an undocumented or not yet
1798
- * supported value.
1799
- */
1800
- fun file (file : MultipartField <InputStream >) = apply { this .file = file }
1801
-
1802
- /* *
1803
- * The API accepts any of the following:
1804
- * - **Binary data** – send the raw bytes as `multipart/form-data`.
1805
- * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.
1806
- * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64.
1807
- *
1808
- * When supplying a URL, the server must receive the response headers within 8 seconds;
1809
- * otherwise the request fails with 400 Bad Request.
1810
- */
1811
- fun file (file : ByteArray ) = file(file.inputStream())
1812
-
1813
- /* *
1814
- * The API accepts any of the following:
1815
- * - **Binary data** – send the raw bytes as `multipart/form-data`.
1816
- * - **HTTP / HTTPS URL** – a publicly reachable URL that ImageKit’s servers can fetch.
1817
- * - **Base64 string** – the file encoded as a Base64 data URI or plain Base64.
1818
- *
1819
- * When supplying a URL, the server must receive the response headers within 8 seconds;
1820
- * otherwise the request fails with 400 Bad Request.
1769
+ * You should usually call [Builder.file] with a well-typed [String] value instead. This
1770
+ * method is primarily for setting the field to an undocumented or not yet supported
1771
+ * value.
1821
1772
*/
1822
- fun file (path : Path ) =
1823
- file(
1824
- MultipartField .builder<InputStream >()
1825
- .value(path.inputStream())
1826
- .filename(path.name)
1827
- .build()
1828
- )
1773
+ fun file (file : MultipartField <String >) = apply { this .file = file }
1829
1774
1830
1775
/* *
1831
1776
* The name with which the file has to be uploaded. The file name can contain:
0 commit comments