Skip to content

Unable to upload file via File field #480

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

Closed
2 tasks done
staticdreams opened this issue Jul 27, 2016 · 22 comments
Closed
2 tasks done

Unable to upload file via File field #480

staticdreams opened this issue Jul 27, 2016 · 22 comments

Comments

@staticdreams
Copy link

staticdreams commented Jul 27, 2016

Make sure these boxes are checked before submitting your issue -- thanks for reporting issues back to Parse Dashboard!

  • You're running version >=2.1.4 of Parse Server.
  • You've searched through existing issues. Chances are that your issue has been reported or resolved before.

Environment Setup

Latest (as of now) Parse Server 2.2.17 running on OpenShift
Latest version of Parse Dashboard 1.0.15 (launched with params on my machine)

Steps to reproduce

I'm able to connect and modify any data in mongoDB, but File fiels does not work. It upon uploading it return {"error":"unauthorized"}

I have specified every single key parse config (master, client, javascript, dotnet, file and rest)

At first I thought it was a parse-server issue, so I tried uploading using curl:

curl -X POST -H "X-Parse-Application-Id: myAppId" -H "X-Parse-REST-API-Key: restKeyHere" -H "Content-Type: text/plain" -T "hello.txt" https://www.myserver.com/parse/files/hello.txt

This worked as expected. So the problem must be with dashboard?

Logs/Trace

Note: If you get a browser JS error please run npm run dev. This will provide source maps and a much more useful stack trace.

@staticdreams
Copy link
Author

Small update: I tried to remove all the client keys and upload worked! But I still need those keys to enforce some sort of security. Even removing one of them is not an option, otherwise they are not enforced (#1789). So I'm guessing it's a bug with Parse Dashboard

@jgaull
Copy link

jgaull commented Aug 7, 2016

I'm seeing the same issue. Running Parse-Dashboard 1.0.15 on heroku. Also tried running locally with no luck. Neither worked. I only have my appId and masterKeys set.

@staticdreams
Copy link
Author

@jgaull the difference being that yours in unable to upload anything at all using just appId and master key. I can do that, but defining other keys breaks everything :) What response are you getting in the console when trying to upload?

@jgaull
Copy link

jgaull commented Aug 10, 2016

@staticdreams Same error as you: {"error":"unauthorized"}

@cleever
Copy link

cleever commented Aug 11, 2016

+1

Failed to load resource: the server responded with a status of 403 (Forbidden)

@Rioner123
Copy link

How big is the file? I had a similar problem for files >1mb. Check out this link and see if it applies:
https://kroltech.com/2014/09/14/quick-tip-increase-upload-size-in-aws-elastic-beanstalk-node-js-env/

@staticdreams
Copy link
Author

@Rioner123 not big. like 200-400k. I ended up removing client keys, but it presented another issue: Anyone, knowing your parse path is able to upload junk files to your server at will: #2484

@cleever
Copy link

cleever commented Aug 29, 2016

@Rioner123 This is happening to me to every file size.
Also I'm getting 403 (Forbidden) error in the Config page too.

@cleever
Copy link

cleever commented Aug 29, 2016

I got my file upload working by putting the javascriptKey in the Parse configurations settings.


{
  "apps": [
    {
      "serverURL": "http://localhost:1337/parse",
      "appId": "myAppId",
      "masterKey": "myMasterKey",
      "appName": "MyApp"
      "javascriptKey": "javascriptKey"
    }
  ]
}

@jeremypiednoel
Copy link

ok @cleever you made my day

@zh-wowtv
Copy link

zh-wowtv commented Oct 5, 2016

I got no error message at all. But the file is not uploaded.

I know the reason already. The file name can't be UTF8, must be ascii because the dashboard is trying to encode the UTF8 so that it of course can't be found.Otherwise I'll see 404 error in browser console.

@cleever
Copy link

cleever commented Oct 5, 2016

@zh-wowtv you need to make sure that file name don't have special characters or accents like "àóéçã()" to work properly.

@jgaull
Copy link

jgaull commented Nov 2, 2016

Unfortunately @cleever's solution didn't work for me.

However, testing tonight I noticed that I'm getting an error on the parse-server side:

2016-11-02T08:06:41.240896+00:00 app[web.1]: error: Uncaught internal server error. [TypeError: res.sendStatus is not a function] TypeError: res.sendStatus is not a function
2016-11-02T08:06:41.240909+00:00 app[web.1]:     at allowCrossDomain (/app/node_modules/parse-server/lib/middlewares.js:245:9)
2016-11-02T08:06:41.240910+00:00 app[web.1]:     at Layer.handle [as handle_request] (/app/node_modules/parse-server/node_modules/express/lib/router/layer.js:95:5)
2016-11-02T08:06:41.240911+00:00 app[web.1]:     at trim_prefix (/app/node_modules/parse-server/node_modules/express/lib/router/index.js:312:13)
2016-11-02T08:06:41.240911+00:00 app[web.1]:     at /app/node_modules/parse-server/node_modules/express/lib/router/index.js:280:7
2016-11-02T08:06:41.240912+00:00 app[web.1]:     at Function.process_params (/app/node_modules/parse-server/node_modules/express/lib/router/index.js:330:12)
2016-11-02T08:06:41.240912+00:00 app[web.1]:     at next (/app/node_modules/parse-server/node_modules/express/lib/router/index.js:271:10)
2016-11-02T08:06:41.240913+00:00 app[web.1]:     at expressInit (/app/node_modules/parse-server/node_modules/express/lib/middleware/init.js:33:5)
2016-11-02T08:06:41.240913+00:00 app[web.1]:     at Layer.handle [as handle_request] (/app/node_modules/parse-server/node_modules/express/lib/router/layer.js:95:5)
2016-11-02T08:06:41.240914+00:00 app[web.1]:     at trim_prefix (/app/node_modules/parse-server/node_modules/express/lib/router/index.js:312:13)
2016-11-02T08:06:41.240914+00:00 app[web.1]:     at /app/node_modules/parse-server/node_modules/express/lib/router/index.js:280:7

Is anybody else seeing this?

Should I report this issue in parse-server?

-EDIT-

A Google search lead me to #375. It had the solution.

I changed my express version in my package.json to ~4.11.x. I got that number from the parse-server-example package.json. Everything works now.

@flovilmart
Copy link
Contributor

@jgaull create to hear that!

@jcguarinpenaranda
Copy link

jcguarinpenaranda commented Dec 4, 2016

Hello,

I have read this thread and changed my express version, as suggested by @jgaull to ~4.11.x. It still doesn't work :S

My package.json dependencies looks like this (omitting several packages):

{
"dependencies": {
    "body-parser": "^1.15.2",
    "express": "^4.11.2",
    "parse": "^1.9.1",
    "parse-dashboard": "^1.0.21",
    "parse-server": "^2.2.25",
    "parse-server-mailgun": "^2.1.7",
    "parse-server-onesignal-push-adapter": "^1.0.0",
    "parse-server-push-adapter": "^1.0.4",
    "parse-server-simple-mailgun-adapter": "^1.0.0",
  }
}

As you can see, I have the most recent version of parse-server and parse-dashboard, as well as the suggested express version.

I have set all the client keys for the parse-server.

I made a simple script to upload a file and it worked, so I know there's no problem with my AWS configuration. But, when I try to upload a File from the Parse Dashboard on Chrome I get an error:

POST /parse/files/cabin.png:1 
https://my-server.herokuapp.com/parse/files/bauble.png 
Failed to load resource: the server responded with a status of 403 (Forbidden) 

So, I tried to upload the same image from Firefox, and I get:

mal formado (bad structured)  bauble.png:1:1

Please help me

@agordeev
Copy link

I got my file upload working by putting the javascriptKey in the Parse configurations settings.

I think this should be documented. Without javascriptKey file upload doesn't work when file adapter is hooked up.

@jeremypiednoel
Copy link

jeremypiednoel commented Dec 11, 2016

@andrew8712 The parse config doesn't work either
You're right should be documented

@marcelocotrim
Copy link

I can't upload files with size larger than 1mb in Dashboard with S3 adapter.

Environment Setup:
Parse Dashboard: 1.0.22
Parse Server: 2.3.1

@Rioner123
Copy link

@ghost
Copy link

ghost commented Dec 29, 2016

The issue is not in relation to filesize issues. It is because you're setting a ClientKey without setting a JavascriptKey.

Add the JavascriptKey to both your dashboard and server config files and you'll find that it works again.

@jcguarinpenaranda
Copy link

Finally got this working by adding the javascriptKey to the dashboard's configuration

@funkenstrahlen
Copy link
Contributor

Adding the javascript key fixed this issue for me too.

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