Parse-dashboard: Unable to upload file via File field

Created on 27 Jul 2016  路  22Comments  路  Source: parse-community/parse-dashboard

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

  • [x] You're running version >=2.1.4 of Parse Server.
  • [x] 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.

Most helpful comment

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"
    }
  ]
}

All 22 comments

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

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.

@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?

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

+1

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

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/

@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

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

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"
    }
  ]
}

ok @cleever you made my day

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.

@zh-wowtv you need to make sure that file name don't have special characters or accents like "脿贸茅莽茫()" to work properly.

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.

@jgaull create to hear that!

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

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.

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

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

@marcelocotrim

Please try this... i suspect this is your problem too
https://kroltech.com/2014/09/14/quick-tip-increase-upload-size-in-aws-elastic-beanstalk-node-js-env/

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.

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

Adding the javascript key fixed this issue for me too.

Was this page helpful?
0 / 5 - 0 ratings