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

The return JSON data is not compatible with jQuery File Upload Plugin's requirement #23

Open
maoxuepeng opened this issue May 28, 2013 · 8 comments

Comments

@maoxuepeng
Copy link

Hi,
I am using jQuery File Upload Plugin's client code and jquery-file-upload-middleware as backend server.
I found a problem is that the jquery-file-upload-middleware return JSON data is not compatible with jQuery File Upload Plugin's requirement, then the problem "Empty file upload result" is always represent. However, the file is upload succeed, just the client can not properly display the result.

I catch the request and found the return JSON data is:
[
{
"name": "iPhone5 docking station.jpeg",
"originalName": "iPhone5 docking station.jpeg",
"size": 9584,
"type": "image/jpeg",
"delete_type": "DELETE",
"url": "http://localhost/uploads/iPhone5%20docking%20station.jpeg",
"delete_url": "http://localhost/product/upload/iPhone5%20docking%20station.jpeg",
"thumbnail_url": "http://localhost/uploads/thumbnail/iPhone5%20docking%20station.jpeg"
}
]

And i google this issue found a issue on jQuery File Upload Plugin's page: blueimp/jQuery-File-Upload#365
There @OneDivZero said the latest jQuery File Upload Plugin's JSON format was changed from: [{file1}, {file2}] to: {files: [{file1}, {file2}]}.

So i try to change the jquery-file-upload-middleware code in lib/filehandler.js:
//res.json(200, result);
//MODIFY & TODO, should sumbit issue to the https://github.com/aguidrevitch/jquery-file-upload-middleware
res.json(200, {files: result});

Then everything is fine.

Is this a bug?

@extradose
Copy link

@ibusybox Nice Job !!!

@ricardobeat
Copy link

Still broken. Line 19 of 'filehandler.js' needs to be changed to

res.json(200, { files: result })

@GroovySquirl
Copy link

Fought this issue for several days... if you use the NEWEST code across the board (e.g. latest middleware + latest JQuery File Upload code), you need to change Line 19 to:

res.json(200, result)

@soomtong
Copy link
Contributor

soomtong commented Oct 7, 2013

@stmaurice cause not updated npm. please use git repos directly

@GroovySquirl
Copy link

Agreed. The NPM is not up to date and doesn't quite work with the newest JQuery version. Repos DO work with the fix above :) (e.g. res.json(200, { files: result }) )

Can someone fix the NPM? The instructions posted in the readme don't work because its not up to date.

@aguidrevitch
Copy link
Owner

hey, will update it soon

@aguidrevitch
Copy link
Owner

I've just released 0.1.0. It works for me with the latest blueimp's code - eg go to examples, npm install, node app.js, upload / delete works fine. Please let me know if it works for you.

@vishal41190
Copy link

Hi i am working with java. I have same problem. I tired to find filehandler.js in my project. But it is not there. Will someone guide me how to change it. Or any other alternative to this is available. Thank you in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants