aboutsummaryrefslogtreecommitdiff
path: root/src/server/DashUploadUtils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/DashUploadUtils.ts')
-rw-r--r--src/server/DashUploadUtils.ts14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts
index 552ab57a5..f13580865 100644
--- a/src/server/DashUploadUtils.ts
+++ b/src/server/DashUploadUtils.ts
@@ -16,7 +16,6 @@ import { clientPathToFile, Directory, pathToDirectory, serverPathToFile } from '
import { resolvedServerUrl } from "./server_Initialization";
import { AcceptableMedia, Upload } from './SharedMediaTypes';
import request = require('request-promise');
-import formidable = require('formidable');
const { exec } = require("child_process");
const parse = require('pdf-parse');
const ffmpeg = require("fluent-ffmpeg");
@@ -26,8 +25,7 @@ export enum SizeSuffix {
Small = "_s",
Medium = "_m",
Large = "_l",
- Original = "_o",
- None = ""
+ Original = "_o"
}
export function InjectSize(filename: string, size: SizeSuffix) {
@@ -71,7 +69,7 @@ export namespace DashUploadUtils {
else {
console.log(`stdout: ${stdout}`);
const data = { size: 0, path: videoId + ".mp4", name: videoId, type: "video/mp4" };
- const file = { ...data, toJSON: () => ({ ...data, filename: data.path.replace(/.*\//, ""), mtime: null, length: 0, mime: "", toJson: () => undefined as any }) };
+ const file = { ...data, toJSON: () => data };
res(MoveParsedFile(file, Directory.videos));
}
});
@@ -80,7 +78,7 @@ export namespace DashUploadUtils {
export async function upload(file: File): Promise<Upload.FileResponse> {
const { type, path, name } = file;
- const types = type?.split("/") ?? [];
+ const types = type.split("/");
const category = types[0];
let format = `.${types[1]}`;
@@ -244,7 +242,7 @@ export namespace DashUploadUtils {
// Use the request library to parse out file level image information in the headers
const { headers } = (await new Promise<any>((resolve, reject) => {
request.head(resolvedUrl, (error, res) => error ? reject(error) : resolve(res));
- }).catch(console.error));
+ }).catch(error => console.error(error)));
try {
// Compute the native width and height ofthe image with an npm module
const { width: nativeWidth, height: nativeHeight } = await requestImageSize(resolvedUrl);
@@ -258,7 +256,7 @@ export namespace DashUploadUtils {
filename,
...results
};
- } catch (e: any) {
+ } catch (e) {
console.log(e);
return e;
}
@@ -274,7 +272,7 @@ export namespace DashUploadUtils {
* @param suffix If the file doesn't have a suffix and you want to provide it one
* to appear in the new location
*/
- export async function MoveParsedFile(file: formidable.File, destination: Directory, suffix: string | undefined = undefined, text?: string): Promise<Upload.FileResponse> {
+ export async function MoveParsedFile(file: File, destination: Directory, suffix: string | undefined = undefined, text?: string): Promise<Upload.FileResponse> {
const { path: sourcePath } = file;
let name = path.basename(sourcePath);
suffix && (name += suffix);