decord/alpha/source/lib/uploader/UploadUtils.tsx
github-actions 1224ea86fd chore: update source for alpha 348.5
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/05xxx/module_5021.js (118.4 MB)
2026-09-26 08:31:33 +00:00

134 lines
3.8 KiB
TypeScript

// Module ID: 5448
// Function ID: 5449
// Name: uploader/UploadUtils
// Dependencies: [5440, 1271, 5449, 1350, 2]
// Exports: calculateProgress, canUploadNatively, doesImageMatchUpload
// Module 5448 (uploader/UploadUtils)
import HTTPUtils from "HTTPUtils" /* 1271 */;
import js_shim_shim from "js_shim/shim" /* 1350 */;
import Upload from "Upload" /* 5440 */;
import size from "module_2" /* 2 */;
const result = size.fileFinishedImporting("lib/uploader/UploadUtils.tsx");
class DefaultHttpClient {
}
const prototype = DefaultHttpClient.prototype;
prototype["sliceBody"] = function sliceBody(body, start) {
let substr = body;
if (body instanceof File) {
substr = body.slice(start);
}
return substr;
};
prototype["doUpload"] = function doUpload(body, fileByteRange) {
fileByteRange = undefined;
if (fileByteRange != null) {
fileByteRange = fileByteRange.fileByteRange;
}
if (null != fileByteRange) {
const self = this;
body.body = this.sliceBody(body.body, fileByteRange.fileByteRange.start);
}
const HTTP = HTTPUtils.HTTP;
return HTTP.put(body);
};
class LibdiscoreHttpClient {
constructor() {
obj = closure_0(closure_1[3]);
if (obj.isLibdiscoreInitialized()) {
return Object.create(new.target.prototype);
} else {
tmp = globalThis;
_Error = Error;
tmp2 = new.target;
str = "Libdiscore is not loaded";
tmp3 = new.target;
error = new Error("Libdiscore is not loaded");
tmp5 = error;
throw error;
}
}
}
LibdiscoreHttpClient.prototype["doUpload"] = function doUpload(body, arg1) {
closure_0 = body;
const httpClientAPI = js_shim_shim.getHttpClientAPI();
if (null == httpClientAPI) {
let _Error2 = Error;
let error = new Error("Libdiscore client is not available");
throw error;
} else {
body = body.body;
let uri1;
if (body != null) {
uri1 = body.uri;
}
if (!tmp3) {
// // eliminated: always false
let _Error = Error;
let error1 = new Error("No file path found in request body");
throw error1;
} else {
const uri = body.body.uri;
const uri2 = body.body.uri;
if (uri.startsWith("file://")) {
let substr = uri2.slice(7);
} else {
substr = uri2;
}
}
tmp3 = undefined !== uri1 && typeof body.body.uri === "string";
}
};
export const doesImageMatchUpload = function doesImageMatchUpload(image, id) {
if (id.id !== image.uri) {
if (id.item.platform === Upload.UploadPlatform.REACT_NATIVE) {
const item = id.item;
const filename = image.filename;
let tmp3 = item.originalUri === image.uri;
if (!tmp3) {
let tmp4 = null == filename;
if (!tmp4) {
const originalUri = item.originalUri;
let hasItem;
if (originalUri != null) {
hasItem = originalUri.includes(filename);
}
tmp4 = !hasItem;
}
tmp3 = !tmp4;
}
return tmp3;
} else {
return false;
}
}
return true;
};
export const calculateProgress = function calculateProgress(loaded, currentSize) {
let num = 0;
if (0 !== currentSize) {
const _Math = Math;
const _Math2 = Math;
num = Math.min(Math.floor(loaded / currentSize * 100), 100);
}
return num;
};
export { DefaultHttpClient };
export const canUploadNatively = function canUploadNatively(platform) {
let fileIsInAppDirResult = platform.platform === Upload.UploadPlatform.REACT_NATIVE;
if (fileIsInAppDirResult) {
fileIsInAppDirResult = null != platform.uri;
}
if (fileIsInAppDirResult) {
fileIsInAppDirResult = tmp(5449).fileIsInAppDir(platform.uri);
const tmpResult = tmp(5449);
}
if (fileIsInAppDirResult) {
fileIsInAppDirResult = tmp(1350).isLibdiscoreInitialized();
const tmpResult2 = tmp(1350);
}
return fileIsInAppDirResult;
};
export { LibdiscoreHttpClient };