From 87c2dd413b89067a1a65e1a71549964f74e8c659 Mon Sep 17 00:00:00 2001 From: xswl Date: Fri, 21 Jul 2023 12:26:10 +0800 Subject: [PATCH] remove path --- package.json | 2 +- src/midjourne.api.ts | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ca289d0..1557ffe 100644 --- a/package.json +++ b/package.json @@ -53,4 +53,4 @@ "tslib": "^2.5.0", "ws": "^8.13.0" } -} \ No newline at end of file +} diff --git a/src/midjourne.api.ts b/src/midjourne.api.ts index cc2038c..1b1fde9 100644 --- a/src/midjourne.api.ts +++ b/src/midjourne.api.ts @@ -13,7 +13,6 @@ import { import { nextNonce, sleep } from "./utils"; import { Command } from "./command"; import async from "async"; -import path from "path"; export class MidjourneyApi extends Command { UpId = Date.now() % 10; // upload id @@ -339,7 +338,7 @@ export class MidjourneyApi extends Command { const response = await this.config.fetch(fileUrl); const fileData = await response.arrayBuffer(); const mimeType = response.headers.get("content-type"); - const filename = path.basename(fileUrl) || "image.png"; + const filename = fileUrl.split("/").pop() || "image.png"; const file_size = fileData.byteLength; if (!mimeType) { throw new Error("Unknown mime type"); @@ -353,7 +352,7 @@ export class MidjourneyApi extends Command { await this.uploadImage(UploadSlot, fileData, mimeType); const resp: DiscordImage = { id: UploadSlot.id, - filename: path.basename(UploadSlot.upload_filename), + filename: UploadSlot.upload_filename.split("/").pop() || "image.png", upload_filename: UploadSlot.upload_filename, }; return resp; @@ -375,7 +374,7 @@ export class MidjourneyApi extends Command { await this.uploadImage(UploadSlot, fileData, mimeType); const resp: DiscordImage = { id: UploadSlot.id, - filename: path.basename(UploadSlot.upload_filename), + filename: UploadSlot.upload_filename.split("/").pop() || "image.png", upload_filename: UploadSlot.upload_filename, }; return resp;