Skip to content

Instantly share code, notes, and snippets.

@warrenkc
Created July 25, 2022 20:41
Show Gist options
  • Save warrenkc/c80538c4548218e027086c6dad2e2ecb to your computer and use it in GitHub Desktop.
Save warrenkc/c80538c4548218e027086c6dad2e2ecb to your computer and use it in GitHub Desktop.
Uppy
var uppy = new Uppy.Core({
autoProceed: true,
restrictions: {
allowedFileTypes: ['image/*']
},
onBeforeFileAdded: (currentFile, files) => {
// Change the file name to the last modified date. This file name doesn't arrive at the server upload handler.
const modifiedFile = {
...currentFile,
name: currentFile.data.lastModified + ".jpg"
}
return modifiedFile
},
});
uppy.use(Uppy.Dashboard, {
inline: true,
disableThumbnailGenerator: true,
showSelectedFiles: false,
target: '#drag-drop-area',
height: 250
})
const { XHRUpload } = Uppy
uppy.use(XHRUpload, {
endpoint: uploadUrl
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment