@@ -28,13 +28,9 @@ import com.imagekit.api.core.http.Headers
2828import com.imagekit.api.core.http.QueryParams
2929import com.imagekit.api.core.toImmutable
3030import com.imagekit.api.errors.ImageKitInvalidDataException
31- import java.io.InputStream
32- import java.nio.file.Path
3331import java.util.Collections
3432import java.util.Objects
3533import java.util.Optional
36- import kotlin.io.path.inputStream
37- import kotlin.io.path.name
3834import kotlin.jvm.optionals.getOrNull
3935
4036/* *
@@ -78,7 +74,7 @@ private constructor(
7874 * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is
7975 * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
8076 */
81- fun file (): InputStream = body.file()
77+ fun file (): String = body.file()
8278
8379 /* *
8480 * The name with which the file has to be uploaded. The file name can contain:
@@ -327,7 +323,7 @@ private constructor(
327323 *
328324 * Unlike [file], this method doesn't throw if the multipart field has an unexpected type.
329325 */
330- fun _file (): MultipartField <InputStream > = body._file ()
326+ fun _file (): MultipartField <String > = body._file ()
331327
332328 /* *
333329 * Returns the raw multipart value of [fileName].
@@ -556,38 +552,15 @@ private constructor(
556552 * When supplying a URL, the server must receive the response headers within 8 seconds;
557553 * otherwise the request fails with 400 Bad Request.
558554 */
559- fun file (file : InputStream ) = apply { body.file(file) }
555+ fun file (file : String ) = apply { body.file(file) }
560556
561557 /* *
562558 * Sets [Builder.file] to an arbitrary multipart value.
563559 *
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.
589562 */
590- fun file (path : Path ) = apply { body.file(path ) }
563+ fun file (file : MultipartField < String > ) = apply { body.file(file ) }
591564
592565 /* *
593566 * The name with which the file has to be uploaded. The file name can contain:
@@ -1197,7 +1170,7 @@ private constructor(
11971170
11981171 class Body
11991172 private constructor (
1200- private val file: MultipartField <InputStream >,
1173+ private val file: MultipartField <String >,
12011174 private val fileName: MultipartField <String >,
12021175 private val token: MultipartField <String >,
12031176 private val checks: MultipartField <String >,
@@ -1235,7 +1208,7 @@ private constructor(
12351208 * @throws ImageKitInvalidDataException if the JSON field has an unexpected type or is
12361209 * unexpectedly missing or null (e.g. if the server responded with an unexpected value).
12371210 */
1238- fun file (): InputStream = file.value.getRequired(" file" )
1211+ fun file (): String = file.value.getRequired(" file" )
12391212
12401213 /* *
12411214 * The name with which the file has to be uploaded. The file name can contain:
@@ -1492,7 +1465,7 @@ private constructor(
14921465 *
14931466 * Unlike [file], this method doesn't throw if the multipart field has an unexpected type.
14941467 */
1495- @JsonProperty(" file" ) @ExcludeMissing fun _file (): MultipartField <InputStream > = file
1468+ @JsonProperty(" file" ) @ExcludeMissing fun _file (): MultipartField <String > = file
14961469
14971470 /* *
14981471 * Returns the raw multipart value of [fileName].
@@ -1726,7 +1699,7 @@ private constructor(
17261699 /* * A builder for [Body]. */
17271700 class Builder internal constructor() {
17281701
1729- private var file: MultipartField <InputStream >? = null
1702+ private var file: MultipartField <String >? = null
17301703 private var fileName: MultipartField <String >? = null
17311704 private var token: MultipartField <String > = MultipartField .of(null )
17321705 private var checks: MultipartField <String > = MultipartField .of(null )
@@ -1788,44 +1761,16 @@ private constructor(
17881761 * When supplying a URL, the server must receive the response headers within 8 seconds;
17891762 * otherwise the request fails with 400 Bad Request.
17901763 */
1791- fun file (file : InputStream ) = file(MultipartField .of(file))
1764+ fun file (file : String ) = file(MultipartField .of(file))
17921765
17931766 /* *
17941767 * Sets [Builder.file] to an arbitrary multipart value.
17951768 *
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.
18211772 */
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 }
18291774
18301775 /* *
18311776 * The name with which the file has to be uploaded. The file name can contain:
0 commit comments