6

I have a Parse Server running on top of a MongoDB, and that's running 100% fine on my Dev Server which is hosted on DigitalOcean. Here I'm able to send GET requests to my server to obtain the image, as well as access the image via it's Parse-Dashboard.

I cloned that droplet to set up a Production Server, and everything is running fine... Except, I can't access the images from Parse that were either cloned from the Dev Server, or ones that I uploaded after I initialized the new Production server. I'm able to send GET requests to obtain all other fields, except for the image files. I also can't access the image file via the Parse-Dashboard - it returns a 404 - Oh no, we can't find that page! error, on the following URL: http://server.ip/parse/files/ProdServer/de632aeb61f7265926e554fabfb25180_image1.png

Other key things to note:

  1. The Dev Server is hosted on a domain that has a SSL; could it be an SSL issue?
  2. I'm initializing the parse-dashboard with the --allowInsecureHTTP flag
  3. Everything (even before the SSL) was working on the Dev Server beforehand
  4. all packages + dependencies are up-to-date

tl;dr

How do I access the image files from my Parse Server, via Parse-Dashboard or GET request?

Steven_
  • 738
  • 2
  • 7
  • 20
  • Compare the URLs of the images when running both locally and on your remote server. Are they the same? Does it perhaps reference your local server? – Jake T. May 01 '17 at 22:06
  • they're the same, except for the ip address. Would you know if Parse Server store the images locally in a specific directory? @JakeT. – Steven_ May 01 '17 at 23:01
  • 1
    It depends on how you set up file storage. If you didn't set up storage, I'm not sure what would happen. I never tried it. Setting up S3 was one of the first things I did with parse-server. If you set up something but it didn't use external resources, and you are able to pull files, then yeah it's only available locally. I'd recommend something external when you move away from development. – Jake T. May 02 '17 at 03:18
  • yeah -- that's what I'm trying to figure out; where locally is it/how is it stored? – Steven_ May 02 '17 at 05:02
  • I'd recommend against using local file storage anyway. S3 is the go to, and there is even a parse-sever adapter for it that is easy to configure. I'd go that route. I don't know much of anything about any local file storage out of the box, but I wouldn't trust its persistence. – Jake T. May 02 '17 at 14:14
  • https://github.com/parse-community/parse-server/blob/master/src/Adapters/Files/GridStoreAdapter.js#L65 verify your configs on the server startup for the file adapter then this will tell you where the files are going . I think the default is local mongo on port 2700n. – Robert Rowntree May 02 '17 at 16:24

1 Answers1

5

A couple methods I tried... Since this was an elaborate process for me, allow me to document the methods I tried to resolve this issue:

The first issue was, do the files exist? If so, where are they stored?

By accessing my parse-dashboard on port 4040, I tried to view the image path via the URL... So I knew it existed somewhere, and I recursively searched my entire server for the file path, but to no avail.

Then with more research I found that any file over 16MB gets converted into a GridFS object i.e. images are stored in my MongoDB. How you access these objects are through a utility called mongofiles.

By running mongofiles -d dbname list I was able to view in a list view all of the images stored on my Parse-Server.

just to ensure the images weren't corrupt...

I also sftp the images over into my local machine, and fortunately I could view them. So the problem was that the images weren't being served correctly...

The next issue was, how come the images aren't being served correctly?

So my parse-dashboard was being served on port 4040, but for some reason, my image file path within their respective URLs were being prefaced with the same port 4040... It turns out that within my Parse-Server config, the parse-server URL was pointing to port 4040, but was being served on ****. By changing my URL back to ****, my images were able to properly render on my parse-dashboard, and I was able to send http requests for the images as well :)


tl;dr make sure your image file path is being served on the same port where your parse-server is being served

Steven_
  • 738
  • 2
  • 7
  • 20