Skip to content

Commit

Permalink
Fix upload
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Sep 2, 2024
1 parent b055fde commit 69b1059
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
17 changes: 7 additions & 10 deletions apps/dashboard/src/components/inbox-upload-zone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { resumableUpload } from "@/utils/upload";
import { createClient } from "@midday/supabase/client";
import { cn } from "@midday/ui/cn";
import { useToast } from "@midday/ui/use-toast";
import { nanoid } from "nanoid";
import { type ReactNode, useEffect, useRef, useState } from "react";
import { useDropzone } from "react-dropzone";

Expand Down Expand Up @@ -52,18 +51,16 @@ export function UploadZone({ children, teamId }: Props) {

setShowProgress(true);

const filePath = [teamId, "inbox"];
// Add uploaded folder so we can filter background job on this
const filePath = [teamId, "inbox", "uploaded"];

try {
await Promise.all(
files.map(async (file, idx) => {
return resumableUpload(supabase, {
files.map(async (file, idx) =>
resumableUpload(supabase, {
bucket: "vault",
path: filePath,
// Add uploaded so we can filter background job on this
file: new File([file], file.name.replace(".", ".uploaded."), {
type: file.type,
}),
file,
onProgress: (bytesUploaded, bytesTotal) => {
uploadProgress.current[idx] = (bytesUploaded / bytesTotal) * 100;

Expand All @@ -76,8 +73,8 @@ export function UploadZone({ children, teamId }: Props) {

setProgress(Math.round(_progress / files.length));
},
});
}),
}),
),
);

// Reset once done
Expand Down
6 changes: 3 additions & 3 deletions packages/jobs/src/inbox/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ client.defineJob({
filter: {
record: {
bucket_id: ["vault"],
// NOTE: This ensures jobs run only for files uploaded through the inbox bulk upload.
path_tokens: [
{
$includes: ".uploaded.",
// NOTE: This ensures jobs run only for files uploaded through the inbox bulk upload.
$includes: "uploaded",
},
],
},
Expand All @@ -38,7 +38,7 @@ client.defineJob({
const { data: inboxData } = await io.supabase.client
.from("inbox")
.insert({
// NOTE: If we can't parse the name using OCR, this will be the fallback name
// NOTE: If we can't parse the name using OCR this will be the fallback name
display_name: filename,
team_id: teamId,
file_path: path_tokens,
Expand Down

0 comments on commit 69b1059

Please sign in to comment.