Skip to content

Commit

Permalink
Fix upload file
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Dec 9, 2024
1 parent 417de7d commit c1678ae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
4 changes: 1 addition & 3 deletions apps/dashboard/jobs/tasks/inbox/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { z } from "zod";
export const inboxUpload = schemaTask({
id: "inbox-upload",
schema: z.object({
id: z.string(),
teamId: z.string().uuid(),
mimetype: z.string(),
size: z.number(),
Expand All @@ -16,7 +15,7 @@ export const inboxUpload = schemaTask({
queue: {
concurrencyLimit: 25,
},
run: async ({ id, teamId, mimetype, size, file_path }) => {
run: async ({ teamId, mimetype, size, file_path }) => {
const supabase = createClient();

const filename = file_path.at(-1);
Expand All @@ -30,7 +29,6 @@ export const inboxUpload = schemaTask({
file_path: file_path,
file_name: filename,
content_type: mimetype,
reference_id: `${id}_${filename}`,
size,
})
.select("*")
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/inbox-upload-zone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function UploadZone({ children, teamId }: Props) {
// Trigger the upload jobs
inboxUpload.execute(
results.map((result) => ({
file_path: [...path, result.file.name],
file_path: [...path, result.filename],
mimetype: result.file.type,
size: result.file.size,
})),
Expand Down
11 changes: 7 additions & 4 deletions apps/dashboard/src/utils/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export async function resumableUpload(
data: { session },
} = await client.auth.getSession();

const fullPath = decodeURIComponent(
[...path, stripSpecialCharacters(file.name)].join("/"),
);
const filename = stripSpecialCharacters(file.name);

const fullPath = decodeURIComponent([...path, filename].join("/"));

return new Promise((resolve, reject) => {
const upload = new tus.Upload(file, {
Expand All @@ -46,7 +46,10 @@ export async function resumableUpload(
},
onProgress,
onSuccess: () => {
resolve(upload);
resolve({
...upload,
filename,
});
},
});

Expand Down

0 comments on commit c1678ae

Please sign in to comment.