@imagekit/javascript 5.0.0-beta.5 → 5.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/imagekit.cjs.js +11 -12
- package/dist/imagekit.esm.js +11 -12
- package/dist/imagekit.min.js +1 -1
- package/dist/interfaces/Transformation.d.ts +4 -4
- package/package.json +1 -1
- package/src/interfaces/Transformation.ts +4 -4
- package/src/upload.ts +11 -13
package/dist/imagekit.cjs.js
CHANGED
|
@@ -119,32 +119,31 @@ const upload = uploadOptions => {
|
|
|
119
119
|
for (key in uploadOptions) {
|
|
120
120
|
if (key) {
|
|
121
121
|
if (key === "file" && typeof uploadOptions.file != "string") {
|
|
122
|
-
formData.
|
|
122
|
+
formData.set('file', uploadOptions.file, String(uploadOptions.fileName));
|
|
123
123
|
} else if (key === "tags" && Array.isArray(uploadOptions.tags)) {
|
|
124
|
-
formData.
|
|
124
|
+
formData.set('tags', uploadOptions.tags.join(","));
|
|
125
125
|
} else if (key === 'signature') {
|
|
126
|
-
formData.
|
|
126
|
+
formData.set("signature", uploadOptions.signature);
|
|
127
127
|
} else if (key === 'expire') {
|
|
128
|
-
formData.
|
|
128
|
+
formData.set("expire", String(uploadOptions.expire));
|
|
129
129
|
} else if (key === 'token') {
|
|
130
|
-
formData.
|
|
130
|
+
formData.set("token", uploadOptions.token);
|
|
131
131
|
} else if (key === "responseFields" && Array.isArray(uploadOptions.responseFields)) {
|
|
132
|
-
formData.
|
|
132
|
+
formData.set('responseFields', uploadOptions.responseFields.join(","));
|
|
133
133
|
} else if (key === "extensions" && Array.isArray(uploadOptions.extensions)) {
|
|
134
|
-
formData.
|
|
134
|
+
formData.set('extensions', JSON.stringify(uploadOptions.extensions));
|
|
135
135
|
} else if (key === "customMetadata" && typeof uploadOptions.customMetadata === "object" && !Array.isArray(uploadOptions.customMetadata) && uploadOptions.customMetadata !== null) {
|
|
136
|
-
formData.
|
|
136
|
+
formData.set('customMetadata', JSON.stringify(uploadOptions.customMetadata));
|
|
137
137
|
} else if (key === "transformation" && typeof uploadOptions.transformation === "object" && uploadOptions.transformation !== null) {
|
|
138
|
-
formData.
|
|
138
|
+
formData.set(key, JSON.stringify(uploadOptions.transformation));
|
|
139
139
|
} else if (key === 'checks' && uploadOptions.checks) {
|
|
140
|
-
formData.
|
|
140
|
+
formData.set("checks", uploadOptions.checks);
|
|
141
141
|
} else if (uploadOptions[key] !== undefined) {
|
|
142
142
|
if (["onProgress", "abortSignal"].includes(key)) continue;
|
|
143
|
-
formData.
|
|
143
|
+
formData.set(key, String(uploadOptions[key]));
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
formData.append("publicKey", uploadOptions.publicKey);
|
|
148
147
|
if (uploadOptions.onProgress) {
|
|
149
148
|
xhr.upload.onprogress = function (event) {
|
|
150
149
|
if (uploadOptions.onProgress) uploadOptions.onProgress(event);
|
package/dist/imagekit.esm.js
CHANGED
|
@@ -115,32 +115,31 @@ const upload = uploadOptions => {
|
|
|
115
115
|
for (key in uploadOptions) {
|
|
116
116
|
if (key) {
|
|
117
117
|
if (key === "file" && typeof uploadOptions.file != "string") {
|
|
118
|
-
formData.
|
|
118
|
+
formData.set('file', uploadOptions.file, String(uploadOptions.fileName));
|
|
119
119
|
} else if (key === "tags" && Array.isArray(uploadOptions.tags)) {
|
|
120
|
-
formData.
|
|
120
|
+
formData.set('tags', uploadOptions.tags.join(","));
|
|
121
121
|
} else if (key === 'signature') {
|
|
122
|
-
formData.
|
|
122
|
+
formData.set("signature", uploadOptions.signature);
|
|
123
123
|
} else if (key === 'expire') {
|
|
124
|
-
formData.
|
|
124
|
+
formData.set("expire", String(uploadOptions.expire));
|
|
125
125
|
} else if (key === 'token') {
|
|
126
|
-
formData.
|
|
126
|
+
formData.set("token", uploadOptions.token);
|
|
127
127
|
} else if (key === "responseFields" && Array.isArray(uploadOptions.responseFields)) {
|
|
128
|
-
formData.
|
|
128
|
+
formData.set('responseFields', uploadOptions.responseFields.join(","));
|
|
129
129
|
} else if (key === "extensions" && Array.isArray(uploadOptions.extensions)) {
|
|
130
|
-
formData.
|
|
130
|
+
formData.set('extensions', JSON.stringify(uploadOptions.extensions));
|
|
131
131
|
} else if (key === "customMetadata" && typeof uploadOptions.customMetadata === "object" && !Array.isArray(uploadOptions.customMetadata) && uploadOptions.customMetadata !== null) {
|
|
132
|
-
formData.
|
|
132
|
+
formData.set('customMetadata', JSON.stringify(uploadOptions.customMetadata));
|
|
133
133
|
} else if (key === "transformation" && typeof uploadOptions.transformation === "object" && uploadOptions.transformation !== null) {
|
|
134
|
-
formData.
|
|
134
|
+
formData.set(key, JSON.stringify(uploadOptions.transformation));
|
|
135
135
|
} else if (key === 'checks' && uploadOptions.checks) {
|
|
136
|
-
formData.
|
|
136
|
+
formData.set("checks", uploadOptions.checks);
|
|
137
137
|
} else if (uploadOptions[key] !== undefined) {
|
|
138
138
|
if (["onProgress", "abortSignal"].includes(key)) continue;
|
|
139
|
-
formData.
|
|
139
|
+
formData.set(key, String(uploadOptions[key]));
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
formData.append("publicKey", uploadOptions.publicKey);
|
|
144
143
|
if (uploadOptions.onProgress) {
|
|
145
144
|
xhr.upload.onprogress = function (event) {
|
|
146
145
|
if (uploadOptions.onProgress) uploadOptions.onProgress(event);
|
package/dist/imagekit.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).ImageKit={})}(this,(function(e){"use strict";var r={message:"Missing file parameter for upload"},t={message:"Missing fileName parameter for upload"},n={message:"Missing public key for upload"},
|
|
1
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).ImageKit={})}(this,(function(e){"use strict";var r={message:"Missing file parameter for upload"},t={message:"Missing fileName parameter for upload"},n={message:"Missing public key for upload"},s={message:"Request to ImageKit upload endpoint failed due to network error"},a={message:"Missing signature for upload. The SDK expects token, signature and expire for authentication."},o={message:"Missing token for upload. The SDK expects token, signature and expire for authentication."},i={message:"Missing expire for upload. The SDK expects token, signature and expire for authentication."},u={message:"Invalid transformation parameter. Please include at least pre, post, or both."},l={message:"Invalid pre transformation parameter."},p={message:"Invalid post transformation parameter."};class c extends Error{constructor(e,r){super(e),this.$ResponseMetadata=void 0,this.name="ImageKitInvalidRequestError",this.$ResponseMetadata=r}}class f extends Error{constructor(e,r){super(e),this.reason=void 0,this.name="ImageKitAbortError",this.reason=r}}class d extends Error{constructor(e){super(e),this.name="ImageKitUploadNetworkError"}}class g extends Error{constructor(e,r){super(e),this.$ResponseMetadata=void 0,this.name="ImageKitServerError",this.$ResponseMetadata=r}}const m=(e,r)=>{let t={...e};const n=h(r);return Object.defineProperty(t,"$ResponseMetadata",{value:n,enumerable:!1,writable:!1}),t},h=e=>{const r=function(e){const r={},t=e.getAllResponseHeaders();Object.keys(t).length&&t.trim().split(/[\r\n]+/).map(e=>e.split(/: /)).forEach(e=>{r[e[0].trim().toLowerCase()]=e[1].trim()});return r}(e);return{statusCode:e.status,headers:r,requestId:r["x-request-id"]}};const y={width:"w",height:"h",aspectRatio:"ar",background:"bg",border:"b",crop:"c",cropMode:"cm",dpr:"dpr",focus:"fo",quality:"q",x:"x",xCenter:"xc",y:"y",yCenter:"yc",format:"f",videoCodec:"vc",audioCodec:"ac",radius:"r",rotation:"rt",blur:"bl",named:"n",defaultImage:"di",flip:"fl",original:"orig",startOffset:"so",endOffset:"eo",duration:"du",streamingResolutions:"sr",grayscale:"e-grayscale",aiUpscale:"e-upscale",aiRetouch:"e-retouch",aiVariation:"e-genvar",aiDropShadow:"e-dropshadow",aiChangeBackground:"e-changebg",aiRemoveBackground:"e-bgremove",aiRemoveBackgroundExternal:"e-removedotbg",contrastStretch:"e-contrast",shadow:"e-shadow",sharpen:"e-sharpen",unsharpMask:"e-usm",gradient:"e-gradient",progressive:"pr",lossless:"lo",colorProfile:"cp",metadata:"md",opacity:"o",trim:"t",zoom:"z",page:"pg",fontSize:"fs",fontFamily:"ff",fontColor:"co",innerAlignment:"ia",padding:"pa",alpha:"al",typography:"tg",lineHeight:"lh",fontOutline:"fol",fontShadow:"fsh",raw:"raw"};var b=e=>"query"===e.transformationPosition,v=function(e){return e&&(y[e]||y[e.toLowerCase()])||""},w=function(){return":"},x=function(){return","},S=function(){return"-"};const k=function(e){return"undefined"!=typeof window?btoa(e):Buffer.from(e,"utf8").toString("base64")},R=new RegExp("^[a-zA-Z0-9-._/ ]*$"),I=new RegExp("^[a-zA-Z0-9-._ ]*$");function E(e){return"string"==typeof e&&"/"==e[e.length-1]&&(e=e.substring(0,e.length-1)),e}function M(e){return"string"==typeof e&&"/"==e[0]&&(e=e.slice(1)),e}function j(e,r){var t=r||"/",n=new RegExp(t+"{1,}","g");return e.join(t).replace(n,t)}function A(e,r){return e=E(M(e)),"plain"===r?"i-"+e.replace(/\//g,"@@"):"base64"===r?"ie-"+encodeURIComponent(k(e)):R.test(e)?"i-"+e.replace(/\//g,"@@"):"ie-"+encodeURIComponent(k(e))}function P(e){const r=[],{type:t,position:n={},timing:s={},transformation:a=[]}=e||{};if(!t)return;switch(t){case"text":{const t=e;if(!t.text)return;const n=t.encoding||"auto";r.push("l-text"),r.push(function(e,r){return"plain"===r?"i-"+encodeURIComponent(e):"base64"===r?"ie-"+encodeURIComponent(k(e)):I.test(e)?"i-"+encodeURIComponent(e):"ie-"+encodeURIComponent(k(e))}(t.text,n))}break;case"image":r.push("l-image");{const t=e,n=t.encoding||"auto";if(!t.input)return;r.push(A(t.input,n))}break;case"video":r.push("l-video");{const t=e,n=t.encoding||"auto";if(!t.input)return;r.push(A(t.input,n))}break;case"subtitle":r.push("l-subtitle");{const t=e,n=t.encoding||"auto";if(!t.input)return;r.push(A(t.input,n))}break;case"solidColor":r.push("l-image"),r.push("i-ik_canvas");{const t=e;if(!t.color)return;r.push("bg-"+t.color)}}const{x:o,y:i,focus:u}=n;o&&r.push("lx-"+o),i&&r.push("ly-"+i),u&&r.push("lfo-"+u);const{start:l,end:p,duration:c}=s;l&&r.push("lso-"+l),p&&r.push("leo-"+p),c&&r.push("ldu-"+c);const f=O(a);return f&&""!==f.trim()&&r.push(f),r.push("l-end"),r.join(x())}const O=function(e){if(!Array.isArray(e))return"";for(var r=[],t=0,n=e.length;t<n;t++){var s=[];for(var a in e[t]){let r=e[t][a];if(null!=r)if("overlay"!==a||"object"!=typeof r){var o=v(a);if(o||(o=a),""!==o)if(["e-grayscale","e-contrast","e-removedotbg","e-bgremove","e-upscale","e-retouch","e-genvar"].includes(o)){if(!0!==r&&"-"!==r&&"true"!==r)continue;s.push(o)}else!["e-sharpen","e-shadow","e-gradient","e-usm","e-dropshadow"].includes(o)||""!==r.toString().trim()&&!0!==r&&"true"!==r?"raw"===a?s.push(e[t][a]):("di"===o&&(r=E(M(r||"")),r=r.replace(/\//g,"@@")),"sr"===o&&Array.isArray(r)&&(r=r.join("_")),"t"===o&&""===r.toString().trim()&&(r="true"),s.push([o,r].join(S()))):s.push(o)}else{var i=P(r);i&&""!==i.trim()&&s.push(i)}}s.length&&r.push(s.join(x()))}return r.join(w())};e.ImageKitAbortError=f,e.ImageKitInvalidRequestError=c,e.ImageKitServerError=g,e.ImageKitUploadNetworkError=d,e.buildSrc=e=>{if(e.urlEndpoint=e.urlEndpoint||"",e.src=e.src||"",e.transformationPosition=e.transformationPosition||"query",!e.src)return"";const r=e.src.startsWith("http://")||e.src.startsWith("https://");var t,n,s;try{r?(t=new URL(e.src),n=!0):(s=new URL(e.urlEndpoint).pathname,t=new URL(j([e.urlEndpoint.replace(s,""),e.src])))}catch(e){return console.error(e),""}for(var a in e.queryParameters)t.searchParams.append(a,String(e.queryParameters[a]));var o=O(e.transformation);return o&&o.length&&(b(e)||n||(t.pathname=j(["tr"+w()+o,t.pathname]))),t.pathname=j(s?[s,t.pathname]:[t.pathname]),o&&o.length&&(b(e)||n)?""!==t.searchParams.toString()?`${t.href}&tr=${o}`:`${t.href}?tr=${o}`:t.href},e.buildTransformationString=O,e.upload=e=>e?new Promise((y,b)=>{const{xhr:v}=e||{};delete e.xhr;const w=v||new XMLHttpRequest;if(!e.file)return b(new c(r.message));if(!e.fileName)return b(new c(t.message));if(!e.publicKey||0===e.publicKey.length)return b(new c(n.message));if(!e.token)return b(new c(o.message));if(!e.signature)return b(new c(a.message));if(!e.expire)return b(new c(i.message));if(e.transformation){if(!Object.keys(e.transformation).includes("pre")&&!Object.keys(e.transformation).includes("post"))return b(new c(u.message));if(Object.keys(e.transformation).includes("pre")&&!e.transformation.pre)return b(new c(l.message));if(Object.keys(e.transformation).includes("post")){if(!Array.isArray(e.transformation.post))return b(new c(p.message));for(let r of e.transformation.post){if("abs"===r.type&&!r.protocol&&!r.value)return b(new c(p.message));if("transformation"===r.type&&!r.value)return b(new c(p.message))}}}var x=new FormData;let S;for(S in e)if(S)if("file"===S&&"string"!=typeof e.file)x.set("file",e.file,String(e.fileName));else if("tags"===S&&Array.isArray(e.tags))x.set("tags",e.tags.join(","));else if("signature"===S)x.set("signature",e.signature);else if("expire"===S)x.set("expire",String(e.expire));else if("token"===S)x.set("token",e.token);else if("responseFields"===S&&Array.isArray(e.responseFields))x.set("responseFields",e.responseFields.join(","));else if("extensions"===S&&Array.isArray(e.extensions))x.set("extensions",JSON.stringify(e.extensions));else if("customMetadata"!==S||"object"!=typeof e.customMetadata||Array.isArray(e.customMetadata)||null===e.customMetadata){if("transformation"===S&&"object"==typeof e.transformation&&null!==e.transformation)x.set(S,JSON.stringify(e.transformation));else if("checks"===S&&e.checks)x.set("checks",e.checks);else if(void 0!==e[S]){if(["onProgress","abortSignal"].includes(S))continue;x.set(S,String(e[S]))}}else x.set("customMetadata",JSON.stringify(e.customMetadata));function k(){var r;return w.abort(),b(new f("Upload aborted",null===(r=e.abortSignal)||void 0===r?void 0:r.reason))}if(e.onProgress&&(w.upload.onprogress=function(r){e.onProgress&&e.onProgress(r)}),e.abortSignal){var R;if(e.abortSignal.aborted)return b(new f("Upload aborted",null===(R=e.abortSignal)||void 0===R?void 0:R.reason));e.abortSignal.addEventListener("abort",k),w.addEventListener("loadend",()=>{e.abortSignal&&e.abortSignal.removeEventListener("abort",k)})}w.open("POST","https://upload.imagekit.io/api/v1/files/upload"),w.onerror=function(e){return b(new d(s.message))},w.onload=function(){if(w.status>=200&&w.status<300)try{var e=JSON.parse(w.responseText),r=m(e,w);return y(r)}catch(e){return b(e)}else if(w.status>=400&&w.status<500)try{e=JSON.parse(w.responseText);return b(new c(e.message??"Invalid request. Please check the parameters.",h(w)))}catch(e){return b(e)}else try{e=JSON.parse(w.responseText);return b(new g(e.message??"Server error occurred while uploading the file. This is rare and usually temporary.",h(w)))}catch(e){return b(new g("Server error occurred while uploading the file. This is rare and usually temporary.",h(w)))}},w.send(x)}):Promise.reject(new c("Invalid options provided for upload")),Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
@@ -425,7 +425,7 @@ export interface TextOverlay extends BaseOverlay {
|
|
|
425
425
|
*
|
|
426
426
|
* Regardless of the encoding method, the input text is always percent-encoded to ensure it is URL-safe.
|
|
427
427
|
*/
|
|
428
|
-
encoding
|
|
428
|
+
encoding?: "auto" | "plain" | "base64";
|
|
429
429
|
/**
|
|
430
430
|
* Control styling of the text overlay.
|
|
431
431
|
*/
|
|
@@ -447,7 +447,7 @@ export interface ImageOverlay extends BaseOverlay {
|
|
|
447
447
|
* - Leading and trailing slashes are removed.
|
|
448
448
|
* - Remaining slashes within the path are replaced with `@@` when using plain text.
|
|
449
449
|
*/
|
|
450
|
-
encoding
|
|
450
|
+
encoding?: "auto" | "plain" | "base64";
|
|
451
451
|
/**
|
|
452
452
|
* Array of transformations to be applied to the overlay image. Supported transformations depends on the base/parent asset.
|
|
453
453
|
*
|
|
@@ -471,7 +471,7 @@ export interface VideoOverlay extends BaseOverlay {
|
|
|
471
471
|
* - Leading and trailing slashes are removed.
|
|
472
472
|
* - Remaining slashes within the path are replaced with `@@` when using plain text.
|
|
473
473
|
*/
|
|
474
|
-
encoding
|
|
474
|
+
encoding?: "auto" | "plain" | "base64";
|
|
475
475
|
/**
|
|
476
476
|
* Array of transformation to be applied to the overlay video. Except `streamingResolutions`, all other video transformations are supported.
|
|
477
477
|
*
|
|
@@ -495,7 +495,7 @@ export interface SubtitleOverlay extends BaseOverlay {
|
|
|
495
495
|
* - Leading and trailing slashes are removed.
|
|
496
496
|
* - Remaining slashes within the path are replaced with `@@` when using plain text.
|
|
497
497
|
*/
|
|
498
|
-
encoding
|
|
498
|
+
encoding?: "auto" | "plain" | "base64";
|
|
499
499
|
/**
|
|
500
500
|
* Control styling of the subtitle.
|
|
501
501
|
*
|
package/package.json
CHANGED
|
@@ -496,7 +496,7 @@ export interface TextOverlay extends BaseOverlay {
|
|
|
496
496
|
* Regardless of the encoding method, the input text is always percent-encoded to ensure it is URL-safe.
|
|
497
497
|
*/
|
|
498
498
|
|
|
499
|
-
encoding
|
|
499
|
+
encoding?: "auto" | "plain" | "base64";
|
|
500
500
|
|
|
501
501
|
/**
|
|
502
502
|
* Control styling of the text overlay.
|
|
@@ -522,7 +522,7 @@ export interface ImageOverlay extends BaseOverlay {
|
|
|
522
522
|
* - Leading and trailing slashes are removed.
|
|
523
523
|
* - Remaining slashes within the path are replaced with `@@` when using plain text.
|
|
524
524
|
*/
|
|
525
|
-
encoding
|
|
525
|
+
encoding?: "auto" | "plain" | "base64";
|
|
526
526
|
|
|
527
527
|
/**
|
|
528
528
|
* Array of transformations to be applied to the overlay image. Supported transformations depends on the base/parent asset.
|
|
@@ -549,7 +549,7 @@ export interface VideoOverlay extends BaseOverlay {
|
|
|
549
549
|
* - Leading and trailing slashes are removed.
|
|
550
550
|
* - Remaining slashes within the path are replaced with `@@` when using plain text.
|
|
551
551
|
*/
|
|
552
|
-
encoding
|
|
552
|
+
encoding?: "auto" | "plain" | "base64";
|
|
553
553
|
|
|
554
554
|
/**
|
|
555
555
|
* Array of transformation to be applied to the overlay video. Except `streamingResolutions`, all other video transformations are supported.
|
|
@@ -576,7 +576,7 @@ export interface SubtitleOverlay extends BaseOverlay {
|
|
|
576
576
|
* - Leading and trailing slashes are removed.
|
|
577
577
|
* - Remaining slashes within the path are replaced with `@@` when using plain text.
|
|
578
578
|
*/
|
|
579
|
-
encoding
|
|
579
|
+
encoding?: "auto" | "plain" | "base64";
|
|
580
580
|
|
|
581
581
|
/**
|
|
582
582
|
* Control styling of the subtitle.
|
package/src/upload.ts
CHANGED
|
@@ -127,36 +127,34 @@ export const upload = (uploadOptions: UploadOptions): Promise<UploadResponse> =>
|
|
|
127
127
|
for (key in uploadOptions) {
|
|
128
128
|
if (key) {
|
|
129
129
|
if (key === "file" && typeof uploadOptions.file != "string") {
|
|
130
|
-
formData.
|
|
130
|
+
formData.set('file', uploadOptions.file, String(uploadOptions.fileName));
|
|
131
131
|
} else if (key === "tags" && Array.isArray(uploadOptions.tags)) {
|
|
132
|
-
formData.
|
|
132
|
+
formData.set('tags', uploadOptions.tags.join(","));
|
|
133
133
|
} else if (key === 'signature') {
|
|
134
|
-
formData.
|
|
134
|
+
formData.set("signature", uploadOptions.signature);
|
|
135
135
|
} else if (key === 'expire') {
|
|
136
|
-
formData.
|
|
136
|
+
formData.set("expire", String(uploadOptions.expire));
|
|
137
137
|
} else if (key === 'token') {
|
|
138
|
-
formData.
|
|
138
|
+
formData.set("token", uploadOptions.token);
|
|
139
139
|
} else if (key === "responseFields" && Array.isArray(uploadOptions.responseFields)) {
|
|
140
|
-
formData.
|
|
140
|
+
formData.set('responseFields', uploadOptions.responseFields.join(","));
|
|
141
141
|
} else if (key === "extensions" && Array.isArray(uploadOptions.extensions)) {
|
|
142
|
-
formData.
|
|
142
|
+
formData.set('extensions', JSON.stringify(uploadOptions.extensions));
|
|
143
143
|
} else if (key === "customMetadata" && typeof uploadOptions.customMetadata === "object" &&
|
|
144
144
|
!Array.isArray(uploadOptions.customMetadata) && uploadOptions.customMetadata !== null) {
|
|
145
|
-
formData.
|
|
145
|
+
formData.set('customMetadata', JSON.stringify(uploadOptions.customMetadata));
|
|
146
146
|
} else if (key === "transformation" && typeof uploadOptions.transformation === "object" &&
|
|
147
147
|
uploadOptions.transformation !== null) {
|
|
148
|
-
formData.
|
|
148
|
+
formData.set(key, JSON.stringify(uploadOptions.transformation));
|
|
149
149
|
} else if (key === 'checks' && uploadOptions.checks) {
|
|
150
|
-
formData.
|
|
150
|
+
formData.set("checks", uploadOptions.checks);
|
|
151
151
|
} else if (uploadOptions[key] !== undefined) {
|
|
152
152
|
if (["onProgress", "abortSignal"].includes(key)) continue;
|
|
153
|
-
formData.
|
|
153
|
+
formData.set(key, String(uploadOptions[key]));
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
formData.append("publicKey", uploadOptions.publicKey);
|
|
159
|
-
|
|
160
158
|
if (uploadOptions.onProgress) {
|
|
161
159
|
xhr.upload.onprogress = function (event: ProgressEvent) {
|
|
162
160
|
if (uploadOptions.onProgress) uploadOptions.onProgress(event)
|