Comments (14)
Something like the following could work (untested):
var form = new require('formidable').IncomingForm()
form.on('progress', function(bytesReceived, bytesExpected) {
console.log(bytesReceived, bytesExpected)
})
var result = yield formidable.parse(form, this)
from koa-formidable.
hello
thanks for the reply
the form works but nothing is printed in the console :/
from koa-formidable.
Did you integrated the form.on('progress', ...)
and yield formidable.parse(...)
in the same order as in the snippet, so the event registration before blocking because of the yield
?
from koa-formidable.
my code is
//parse le form
var f = new require('formidable').IncomingForm()
f.on('progress', function(bytesReceived, bytesExpected) {
console.log(bytesReceived+'/'+bytesExpected)
})
console.log(f)
var form = yield formidable.parse(f, this)
so yes :)
from koa-formidable.
hello
this is very strange :
1/ the progress event seems called only once the file is totally uploaded..
2/ why the hell the file is not viewable while uploading in my uploadDir, i can only see it when the file is totaly uplodded i don t know where it s writed while uploading :/
thanks !
from koa-formidable.
These issues seem to be more related to formidable itself than to the koa wrapper. Anyway:
- Maybe you will get more events when trying a bigger file or when uploading not from localhost to localhost?
- try the term temporary path on https://github.com/felixge/node-formidable
from koa-formidable.
hello
i try with files of 300mo to 13 GB ! can t do bigger :) from localhost or to my server same thing
i try to update my formidable package then look at this
you mean the file.path = null ?
normally it seems i need to set this in the fileBegin event but this event do not work for the moment, i retry
brb !
from koa-formidable.
Yes, I mean the sentence above that
The path this file is being written to. You can modify this in the 'fileBegin' event in case you are unhappy with the way formidable generates a temporary path for your files.
However, I never changed the temporary path myself. So cannot actually help with that, but it is common practice to upload files to a temporary location and just move them to the final location once uploading has finished.
For the progress issue I would recommend to search stackoverflow and formidable's issue page.
from koa-formidable.
same problem ....
here s my route, i stop it with a return just after parse now to test...
// post add function
module.exports.add = function *() {
var socket = io('http://localhost:3000');
var results = {};
doc = {};
docs = [];
//parse le form
var f = new formi.IncomingForm();
f.uploadDir = "/data/websites/traceroute/uploads";
f.on('fileBegin', function(name, file) {
console.log(name + ' ' + file + " upload started!")
});
f.on('progress', function(bytesReceived, bytesExpected) {
socket.emit('formMsg', bytesReceived+'/'+bytesExpected)
})
console.log(f)
var form = yield formidable.parse(f, this)
return;
}
i can t see any log before the file is 100% uploaded
from koa-formidable.
as you can see i already use a custom uploadDir and it works but this file is writed there after upload completed not while uploading Oo
from koa-formidable.
I think there is a difference between the upload dir and the temporary location during upload.
from koa-formidable.
node-formidable/formidable#377
from koa-formidable.
yes but i think i can t use this since the fileBegin event do not work :/
i ll try ...
from koa-formidable.
Is maybe fixed with version 1.1.0
. Better late than never
from koa-formidable.
Related Issues (6)
- Put form data in this.req.body or this.request.body? HOT 2
- .FIle and events HOT 1
- deprecation warning HOT 1
- need tests HOT 1
- the events of formidable do not work. HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from koa-formidable.