No way to update status when using FileUpload custom handler

UI Components for React
Post Reply
slatifi
Posts: 1
Joined: 12 Mar 2023, 18:03

12 Mar 2023, 18:12

Hi,

I am using the file upload component with a custom handler but have found no way from the docs to update the upload status of the files, it just stays as "Pending" for each file.

I am using a upload handler like below:

Code: Select all

	const uploadFiles = (e) => {
		const keys = []
		e.files.map(f => {
			return s3.putObject({
				Bucket: <bucket_name_here>,
				Key: <key_here>,
				Body: f
			}, function (err, data) {
				if (err) {
					console.log("Error", err);
				}
				if (data) {
					console.log("Upload Success", data);
				}
			})
		})
		setAttachments(keys);
	}
And my config for the FileUpload component is below:

Code: Select all

				<FileUpload
					name="demo[]"
					multiple
					maxFileSize={2000000}
					customUpload
					uploadHandler={uploadFiles}
					emptyTemplate={<p className="m-0">Drag and drop files to here to upload.</p>}
				/>
Does anyone know how I can change these tags to Completed (like in the docs demo - https://primereact.org/fileupload/#advanced) once the function is finished exucuting?

habubey
Posts: 61
Joined: 24 Aug 2022, 13:17

13 Mar 2023, 15:05

Hey there,

I would like to recommend that you take a look at the PrimeReact library's "FileUpload.js" file located in the "/components/lib/fileupload/" directory. In particular, I would like to draw your attention to the status change code contained therein, specifically the "createFiles" and "createUploadedFiles" functions.

Best
Bugra Beyduz
PrimeReact Core Developer
Github profile: https://github.com/habubey

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest