onBeforeFileAdded callback issue
See original GitHub issueHi,
I work on image upload, and I have a restrictions
on allowedFileTypes
and maxFileSide
.
My onBeforeFileAdded
looks like:
onBeforeFileAdded: (currentFile, files) => {
debugger
if (currentFile.data.size > uppy.opts.restrictions.maxFileSize) {
...
}
When I choose file temp.img
that violates restrictions, the callback onBeforeFileAdded
is called and it stops on debugger
.
Then I let debugger to go, and everything is fine
Then I chose the same file temp.img
that violates restrictions, the callback onBeforeFileAdded
it do not stop on debugger
, in other words it is not called at all.
Then i chose some other file like temp_222.img
file that violates restrictions, the callback onBeforeFileAdded
is called and it stops on debugger
.
Thanks! 😃 and
Here is my config:
$().ready(function() {
var uppy = Uppy.Core({
debug: true,
autoProceed: true,
restrictions: {
maxFileSize: 1000,
maxNumberOfFiles: false,
minNumberOfFiles: false,
allowedFileTypes: ['image/*']
},
onBeforeFileAdded: (currentFile, files) => {
debugger
if (currentFile.data.size > uppy.opts.restrictions.maxFileSize) {
const message = `Error: ${currentFile.name} file exceeds maximum allowed size of 20 MB.`;
const timeStamp = Date.now();
$('.Informer').append( "<p class='" + timeStamp + " link'> " + message + "</p>").find("." +
timeStamp).delay(10000).slideUp();
// return false
}
},
})
.use(Uppy.FileInput, {
target: '.DashboardContainer',
allowMultipleFiles: true,
pretty: true,
inputName: 'files[]',
locale: {
strings: {
chooseFiles: 'Select to upload'
}
}
})
.use(Uppy.ThumbnailGenerator)
.use(Uppy.ProgressBar, {
target: '.DashboardContainerStatusBar',
})
.use(Uppy.AwsS3, {...})
.run()
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
const - Uppy
onBeforeFileAdded : (currentFile, files) => currentFile. A function run before a file is added to Uppy. It gets passed (currentFile, files) where currentFile...
Read more >How to rename a file in uppy? javascript - Stack Overflow
You need to make sure that the callback you posted is passed into your main uppy core initialization. It should work then as...
Read more >Limit uploader max file size? - Webix Forum
I have a problem with my upload logic. IIS (Microsoft) returns a ... However, webix does not catch this in the callback of...
Read more >@filerobot/core - npm
Core module for the extensible JavaScript file upload widget with support for drag&drop, resumable uploads, previews, restrictions, file processing/encoding ...
Read more >transloadit - Bountysource
const minFileSize = 1 * 1024 * 1024; //1MB onBeforeFileAdded: ... Not sure if the issue related to uppy companion itself or to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@goto-bus-stop, we still have this issue, in that if we try to select the same file twice, -
onBeforeFileAdded()
is not called the second time (and is called again for this file if we try to select some completely different file in between the attempts). I will look into it!Thanks on replay, I’m also not sure if this is issue, but I tried next:
First I choose file
temp.img
that violates restrictions, the callbackonBeforeFileAdded
is called and it stops ondebugger
.Second I choose file
temp.img
that violates restrictions, the callbackonBeforeFileAdded
is not called and it do not stops ondebugger
.Third I choose file
temp_222.img
that violates restrictions, the callbackonBeforeFileAdded
is called and it stops ondebugger
.Fourth I choose file
temp.img
that violates restrictions, the callbackonBeforeFileAdded
is called and it stops ondebugger
.I really don’t know if it is issue or not but for me this behaviour is a little unusual. In Fourth example if it didn’t call the
onBeforeFileAdded
callback it would be ok, but on this way it is unusual.If You’re going to plan something about this, please notify me about your decision. Thank You! 😃