Skip to content

Commit

Permalink
remove path
Browse files Browse the repository at this point in the history
  • Loading branch information
zcpua committed Jul 21, 2023
1 parent 3e78cc0 commit 87c2dd4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@
"tslib": "^2.5.0",
"ws": "^8.13.0"
}
}
}
7 changes: 3 additions & 4 deletions src/midjourne.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 87c2dd4

Please sign in to comment.