Cannot access photos using local Parse server + mongoDB on AWS
Issue Description
Images in my app fail to show up when I test a local Parse server (2.2.17) + mongoDB on AWS. Other data is loaded correctly. Currently, my app is working fine since I'm using Parse.com + mongoDB on AWS.
Cannot access images either via local dashboard
Steps to reproduce.
Expected Results
Clicking image links in dashboard should show me the corresponding images in browsers.
Actual Outcome
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>8124E9661D06FDC6</RequestId>
<HostId>
F4GEobuPCvBxUk510sQeCbKIrtFlP04JHqDAWUo8kNyBouVUnqvgL87NXWo5ji/08NFnM8rd7iI=
</HostId>
</Error>
Environment Setup
- Server
- parse-server version (Be specific! Don't say 'latest'.) : 2.2.17
- Operating System: OS X Yosemite
- Hardware: MacBook Pro (15-inch, Mid 2010)
- Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Localhost
- Database
- MongoDB version: 3.0.9
- Storage engine: wiredTiger
- Hardware: EC2 t2.micro
- Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): AWS
@yifli could you provide more data? For example, is this a new app on parse server, or migrated from Parse? If it was migrated from parse, are you initializing your server with fileKey? Did you migrate your files already? Are you using a storage adapter like the S3Adapter?
Check your S3 bucket policy for your parse uploaded images, it is likely that it's not properly configured for public read.
@natanrolnik I'm migrating this app from Parse. In the app, I'm not initializing the server with fileKey (but I cannot access images either via dashboard). I already finished database migration. Like I said, all the other data is read correctly in my app (but if I use Parse.com, all the data including images can be read without problems). I'm not using storage adapter.
@flovilmart Do I check S3 bucket policy on AWS? I'm not sure how to do it. If it's a problem on AWS side, how come images can show up if I use Parse.com + AWS?
Can you provide the URL's for the failing image?
@yifli I asked about the files migration, not database migration. If you are migrating the apps from Parse, the files are located in Parse's S3 bucket, which are unknown to your server. The dashboard is connected to the api.parse.com/1 or to your server's URL? I guess that might be the problem. Go to the settings of your app in Parse.com, get the fileKey, and use it to initialise your server; according to what you described, I'm pretty sure that's the case.
@natanrolnik In the case where I cannot access my images, the dashboard is connected to my local Parse server. I'll try your suggestion after I get off from work today.
So how am I supposed to migrate my files? Does migration guide mention this?
If I understand it correctly, initializing my server with the fileKey basically gives my app the permission to access the files located in Parse's S3 bucket. I need to move the files before Parse shuts down its service, right?
@yifli exactly. You can take a look at: https://github.com/parse-server-modules/parse-files-utils
@flovilmart http://files.parsetfss.com/1e9a16b7-c483-400b-9db8-20c38b522adf/tfss-4e0fef95-5be8-465d-927a-592711ac4909-dishImage.jpg.
I don't see any error... If the issue is on the dashboard, please open it in the dashboard...
curl -vvv -X HEAD http://files.parsetfss.com/1e9a16b7-c483-400b-9db8-20c38b522adf/tfss-4e0fef95-5be8-465d-927a-592711ac4909-dishImage.jpg
* Trying 52.84.4.43...
* Connected to files.parsetfss.com (52.84.4.43) port 80 (#0)
> HEAD /1e9a16b7-c483-400b-9db8-20c38b522adf/tfss-4e0fef95-5be8-465d-927a-592711ac4909-dishImage.jpg HTTP/1.1
> Host: files.parsetfss.com
> User-Agent: curl/7.43.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: image/jpeg
< Content-Length: 542005
< Connection: keep-alive
< Date: Fri, 02 Sep 2016 15:09:45 GMT
< Last-Modified: Thu, 04 Aug 2016 06:13:43 GMT
< ETag: "e69894095e6613a860e7ad4d8b706b2d"
< x-amz-version-id: 44z7uAEpSyHwr31wYzSGZwoy1Pv62i7j
< Accept-Ranges: bytes
< Server: AmazonS3
< X-Cache: Miss from cloudfront
< Via: 1.1 bfed147b9db2f9e0776c1d171ff57d14.cloudfront.net (CloudFront)
< X-Amz-Cf-Id: JJQPk-uabwb0ivVVtuYc3JFi7QZozlgLsJxzlkDEXPKkJgIs7fdoZg==
<
try this
var api = new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/seaker_db',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
fileKey: process.env.FILE_KEY || 'xxxxxx-xxxx-xxxx-xxxx-xxxx',
...
...