felixrieseberg / felixrieseberg/React-Dropzone-Component
Dynamically changing postUrl config parameter
- Dominant language
- JavaScript
- Stars
- 999
- Forks
- 148
- PR merge metrics
- No merged PRs in 30d
Description
I am using react dropzone component https://github.com/felixrieseberg/React-Dropzone-Component to facilitate the dragging and dropping of files onto a site.
I want each file that gets dropped onto the dropzone to get posted to a different url (AWS Pre-Signed URL). Essentially I want the the component config parameter 'postUrl' to dynamically change as this pre-signed URL changes.
I currently have the following component configuration set
class Uploader extends React.Component {
constructor(props){
super(props);
this.dropzone = 'null'
}
config = () => (
{
iconFiletypes: ['.jpg', '.png', '.gif'],
showFiletypeIcon: true,
postUrl: this.dropzone.options.url || 'no-url'
}
);
eventHandlers = () => (
{
processing: function(file) {
},
init: dz => this.dropzone = dz,
}
);
djsConfig = (requestID=this.props.requestId) => (
{
addRemoveLinks: false,
acceptedFiles: "image/jpeg,image/png,image/gif",
autoProcessQueue: true,
init: function () {
this.on("processing", async (file) => {
const presigned_url = await uploadUrl(file, requestID, () => {})
this.options.url = presigned_url;
});
}
}
);
}
I get the following error when I load the page/component:
`Uncaught TypeError: Cannot read property 'url' of undefined`
Updating the `options.url` on the Dropzone object via `djsConfig` when a file is processed doesn't get the chance to update the `postUrl: this.dropzone.options.url` as I would like?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing how the React dropzone component reads its postUrl configuration and how djsConfig and eventHandlers initialize Dropzone. Reproduce the undefined options.url error with the Uploader example, then verify whether a per-file presigned URL can be applied before processing and whether the resulting request uses that URL.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100