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
I am trying to make a form where a user should be able to add their resume into the form and then upload this file to AWS S3 bucket, how should i handle this?
constformSchema=z.object({jobTitle: z.string().min(2,{message: "Job Title must be at least 2 characters long"}),companyName: z.string().min(2,{message: "Company Name must be at least 2 characters long"}),jobLocation: z.string().min(2,{message: "Job Location must be at least 2 characters long"}),jobDescription: z.string().min(5,{message: "Job Description must be at least 5 characters long"}),jobType: z.string(),applicationDate: z.string(),applicationStatus: z.string(),applicationLink: z.string().optional(),applicationNotes: z.string().optional(),jobReferenceNumber: z.string().optional(),applicationDeadline: z.string().optional().refine((value)=>!value||/^\d{4}-\d{2}-\d{2}$/.test(value),{message: "Application Deadline must be a valid date (YYYY-MM-DD)",}),resume: z.custom<File>((v)=>vinstanceofFile,{message: "Resume must be a valid file",}),coverLetter: z.string().optional(),referral: z.boolean().default(false),referralSource: z.string().optional(),referralContact: z.string().optional(),});exportconstuploads=(form: any)=>{return(<divclassName="space-y-6"><FormFieldcontrol={form.control}name="resume"render={({ field })=>(<FormItem><FormLabelclassName="flex items-center text-sm font-medium text-gray-700"><FileTextclassName="mr-2 h-4 w-4"/>
Resume
</FormLabel><FormControl><divclassName="mt-1 flex items-center"><Inputtype="file"accept=".pdf,.doc,.docx"onChange={(e)=>field.onChange(e.target.files?.[0]||null)}className="hidden"id="resume-upload"/><labelhtmlFor="resume-upload"className="cursor-pointer inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"><PaperclipclassName="mr-2 h-4 w-4"/>
Upload Resume
</label></div></FormControl><FormMessageclassName="text-xs text-red-500 mt-1"/></FormItem>)}/><FormFieldcontrol={form.control}name="coverLetter"render={({ field })=>(<FormItem><FormLabelclassName="flex items-center text-sm font-medium text-gray-700"><FileTextclassName="mr-2 h-4 w-4"/>
Cover Letter
</FormLabel><FormControl><divclassName="mt-1 flex items-center"><Inputtype="file"accept=".pdf,.doc,.docx"onChange={(e)=>field.onChange(e.target.files?.[0]||null)}className="hidden"id="cover-letter-upload"/><labelhtmlFor="cover-letter-upload"className="cursor-pointer inline-flex items-center px-4 py-2 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"><PaperclipclassName="mr-2 h-4 w-4"/>
Upload Cover Letter
</label></div></FormControl><FormMessageclassName="text-xs text-red-500 mt-1"/></FormItem>)}/></div>);};asyncfunctiononSubmit(values: FormValues){constformData: FormData=newFormData();constmongoUser=awaitfindUserByClerkId(user?.id);formData.append("userId",mongoUser?._id);(Object.keys(values)asArray<keyofFormValues>).forEach((key)=>{constvalue=values[key];if(value!==undefined&&value!==null){formData.append(key,value.toString());}});mutateAsync(formData);}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to make a form where a user should be able to add their resume into the form and then upload this file to AWS S3 bucket, how should i handle this?
Beta Was this translation helpful? Give feedback.
All reactions