You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I was developing a open application form for my application,
when i test it using ngrok the onUploadCompleted is triggered and update my job application table.
When i try the same test in the vercel environement the create job application and the upload is working, but not the update to cv_url column.
form action function:
asyncfunctionaction(data: z.infer<typeofschema>){try{setLoading(true);constfile=data.cv;constfileNames=file.name;constapiCall=awaitCreateCandidature(data);if(apiCall.status===201){letcandidature: Candidature=awaitapiCall.json();awaitupload(fileNames,file,{access: "public",handleUploadUrl: "/api/cv/upload",clientPayload: candidature.id.toString(),});toast({title: "Candidature created",description: "Candidature has been created successfully",});setLoading(false);form.reset();}else{setLoading(false);toast({title: "Error",description: "An error has occurred",});}}catch(error){setLoading(false);console.error(error);toast({title: "Error",description: "An error has occurred",});}}
my upload route:
exportasyncfunctionPOST(request: Request): Promise<NextResponse>{constbody=(awaitrequest.json())asHandleUploadBody;try{constjsonResponse=awaithandleUpload({
body,
request,onBeforeGenerateToken: async(pathname,clientPayload)=>{// Generate a client token for the browser to upload the file// ⚠️ Authenticate and authorize users before generating the token.// Otherwise, you're allowing anonymous uploads.return{allowedContentTypes: ["application/pdf",],tokenPayload: JSON.stringify({
pathname,
clientPayload,}),};},onUploadCompleted: async({ blob, tokenPayload })=>{// Get notified of client upload completion// ⚠️ This will not work on `localhost` websites,// Use ngrok or similar to get the full upload flowconsole.log("blob upload completed",blob,tokenPayload);try{// Run any logic after the file upload completed//update candidatureif(!tokenPayload)thrownewError("No token payload found");constpayload=JSON.parse(tokenPayload);console.info("Updating candidature payload="+payload);!payload?.clientPayload
? console.error("No client payload found")
: console.info("Client payload found");constcandidature=awaitprisma.candidature.update({where: {id: Number(payload.clientPayload)},data: {cv: blob.url,},});console.info("Candidature updated",candidature);}catch(error){console.error("Error updating candidature",error);thrownewError("Could not update candidature");}},});returnNextResponse.json(jsonResponse);}catch(error){returnNextResponse.json({error: (errorasError).message},{status: 400},// The webhook will retry 5 times waiting for a 200);}}
The text was updated successfully, but these errors were encountered:
Hi! I've just had a problem where blob was uploaded but onUploadCompleted would not trigger so I've tried the same "happy path" with another domain (assigned to my deployment by vercel) and it has worked :D
Package.json info:
"next": "14.2.3"
,"@vercel/blob": "^0.23.3"
Hello,
I was developing a open application form for my application,
when i test it using ngrok the
onUploadCompleted
is triggered and update my job application table.When i try the same test in the vercel environement the create job application and the upload is working, but not the update to cv_url column.
form action function:
my upload route:
The text was updated successfully, but these errors were encountered: