Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event upload-success called twice when using AWS S3 plugin. #3447

Open
ndr47 opened this issue Jan 22, 2022 · 2 comments
Open

Event upload-success called twice when using AWS S3 plugin. #3447

ndr47 opened this issue Jan 22, 2022 · 2 comments
Labels
AWS S3 Plugin that handles uploads to Amazon AWS S3 Bug

Comments

@ndr47
Copy link

ndr47 commented Jan 22, 2022

When I use AWS S3 plugin, for each file I am uploading, I get the event upload-success firing twice.

new Uppy(this.uppy_options)
	.use(AwsS3, this.uppy_aws_options)
	.use(XHRUpload, this.uppy_xhr_options)
	.on('file-added', (file) => {
		// THIS IS CALLED ONCE
		console.log('Added file', file);
	})
	.on('upload', (data) => {
		// THIS IS CALLED ONCE
		console.log(`Starting upload ${data.id} for files ${data.fileIDs}`);
	})
	.on('upload-progress', (file, progress) => {
		// THIS IS CALLED TWICE (for each progress)
		console.log(file, progress);
	})
	.on('upload-success', (file, response) => {
		// THIS IS CALLED TWICE
		console.log('Upload successful', file, response);
	});
const uppy_aws_options = {
	getUploadParameters (file:any) {
		return my_custom_method_that_return_a_presigned_url(file.name, file.size, file.type)
			.then((res) => {
				return {
					method: 'put',
					url: res.presignedURL,
					headers: {
						'Content-Type': file.type,
					}
				};
			});
		}
};
const uppy_options = {
	autoProceed: false,
	allowMultipleUploadBatches: true,
	debug: true,
	restrictions: {
		maxFileSize: null,
		minFileSize: null,
		maxTotalFileSize: null,
		maxNumberOfFiles: null,
		minNumberOfFiles: null,
		allowedFileTypes: null,
	}
};
const uppy_xhr_options = {
	endpoint: target,
	fieldName: 'file',
	formData: true
};

Is Uppy uploading the file also when it is fetching the presignedURL?

I believe I should get the event upload-success only once, or am I missing something?

@ivanhlb
Copy link

ivanhlb commented Dec 5, 2022

I am also having a similar issue, but mine is doing it thrice. Did you have any luck finding out what was causing it?

@crice88
Copy link

crice88 commented Mar 16, 2023

I'm running into the same issue here. I'd like to be able to optimistically update my query cache but can't as it seems to be firing right away, then again when the file finishes uploading. Any help or ideas would be appreciated.

@arturi arturi removed the Triage label Jul 6, 2023
@Murderlon Murderlon added the AWS S3 Plugin that handles uploads to Amazon AWS S3 label Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AWS S3 Plugin that handles uploads to Amazon AWS S3 Bug
Projects
None yet
Development

No branches or pull requests

5 participants