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

Support for userData in upload options #547

Closed
jobh opened this issue Aug 25, 2023 · 4 comments
Closed

Support for userData in upload options #547

jobh opened this issue Aug 25, 2023 · 4 comments
Labels
completed enhancement New feature or request

Comments

@jobh
Copy link

jobh commented Aug 25, 2023

Is your feature request related to a problem? Please describe.

It would be very nice to be able to attach user data to an upload (batch). An example is shown below. Note, this already works, but it feels hacky and is not explicitly supported, plus it is contrary to the typescript definitions.

Describe the solution you'd like

const { upload } = useUploadyContext();
const handleDrop = (files) => {
    const projects = deriveProjectsFromFiles(files);
    projects.forEach((project) => upload(project.files, { userData: { project } } )
};

and then

    useBatchAddListener((batch, options) => {
        const { project } = options.userData;
        handleAddRow({ id: batch.id, name: project.name });
    });

Describe the solution you'd like

I think that adding a typescript definition

userData?: object;

on UploadOptions would be sufficient, implicitly declaring this as supported and also making TS happy.

Describe alternatives you've considered

The current situation (works but is unsupported) is actually ok with me, I'm registering this issue in case you'd like to declare it supported — because I think it would be a useful feature.

@yoavniran
Copy link
Collaborator

Hey @jobh why not use the Params property of the UploadOptions?

@jobh
Copy link
Author

jobh commented Aug 25, 2023

why not use the Params property of the UploadOptions?

Hi @yoavniran,

The reason is that I don't want to send the user-data object as a request parameter. I only need it internally on the frontend, to associate the upload batch with the underlying object that is being uploaded (project in my example). This is for example to populate an upload table with both project name and batch-id (for progress/abort purposes).

@yoavniran
Copy link
Collaborator

got it. sounds reasonable. I will give it some thought and most likely add it very soon

@yoavniran yoavniran added enhancement New feature or request no-stale labels Aug 25, 2023
@jobh
Copy link
Author

jobh commented Aug 25, 2023

Thanks @yoavniran!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants