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

ROOT_URL and File Not Found :( #85

Closed
palpinter opened this issue May 25, 2016 · 12 comments
Closed

ROOT_URL and File Not Found :( #85

palpinter opened this issue May 25, 2016 · 12 comments

Comments

@palpinter
Copy link

palpinter commented May 25, 2016

Hi,

I'm afraid I don't understand using ROOT_URL in this package. Please help, what is the correct way.

Example:
When I upload images in my dev system locally with ordinary:
meteor --port 3000
everything works as expected.

But when I want to change path with ROOT_URL to access same system for testing external access with:
ROOT_URL=http://palpinter.dlinkddns.com:3000 meteor --port 3000
I receive 'File Not Found :(' error message for all uploaded images.

And if change the port only:
meteor --port 3030
the result is the same, ''File Not Found :(' for all uploaded images.

How can I change ROOT_URL to access my uploaded images?

Thx
Pal

@dr-dimitru
Copy link
Member

dr-dimitru commented May 25, 2016

  1. Have you checked the generated links by fileURL template helper?
  2. Can you locate files to confirm what they are uploaded and exists?

fileURL template helper is using __meteor_runtime_config__.ROOT_URL which is set from ROOT_URL env.var, see here

@palpinter
Copy link
Author

  1. Yes I generate links with fileURL, and I change the port only, so...
  2. Of course, if I change back the port number, all image visible again.

@palpinter
Copy link
Author

Maybe the collection definition wrong?

Images = new FilesCollection(
collectionName: 'images'
allowClientCode: false
storagePath: 'ak/images'
onBeforeUpload: (file) ->
# Allow upload files under 10MB, and only in png/jpg/jpeg formats
if file.size <= 10485760 and /png|jpg|jpeg/i.test(file.ext)
true
else
'Please upload image, with size equal or less than 10MB'
)

@dr-dimitru
Copy link
Member

dr-dimitru commented May 25, 2016

  1. Definition looks ok
  2. The link is changing? Port is not missed? Could you post the link?
  3. What output you're getting when passing __meteor_runtime_config__.ROOT_URL to browser's console?
  4. Have you tried to set debug to true, could you post here Server's output with debug option?

@palpinter
Copy link
Author

palpinter commented May 25, 2016

OK, this very strange.
I have two running system, the second rsynced from the first.
The first started with
ROOT_URL=http://palpinter.dlinkddns.com:3030 meteor --port 3030
The following (and all) picture is exist:
http://palpinter.dlinkddns.com:3030/cdn/storage/images/eAy8AJk5vYtmodWTi/original/eAy8AJk5vYtmodWTi.jpg
meteor_runtime_config.ROOT_URL is 'http://palpinter.dlinkddns.com:3030'

The second started with:
ROOT_URL=http://palpinter.dlinkddns.com:3060 meteor --port 3060
The same picture:
http://palpinter.dlinkddns.com:3060/cdn/storage/images/eAy8AJk5vYtmodWTi/original/eAy8AJk5vYtmodWTi.jpg
the result is: 'File Not Found :('
meteor_runtime_config.ROOT_URL is 'http://palpinter.dlinkddns.com:3060'

Both instance is absolutely identical. Everything works in the app except images.

And if the first started with 3060 port, and the second with 3030, the second will works, and the first wont.

@palpinter
Copy link
Author

You can access both of them now. There is english language version. You can select with flags in upper right corner.

@dr-dimitru
Copy link
Member

dr-dimitru commented May 25, 2016

From my end both urls returns 404 (may it be cache on your machine?):

  1. http://palpinter.dlinkddns.com:3060/cdn/storage/images/eAy8AJk5vYtmodWTi/original/eAy8AJk5vYtmodWTi.jpg
  2. http://palpinter.dlinkddns.com:3030/cdn/storage/images/eAy8AJk5vYtmodWTi/original/eAy8AJk5vYtmodWTi.jpg
  3. Are you sure those files is transferred via rsync?
  4. Have you checked permissions after transferring files via rsync? Try to run chmod -R 777 /path/to/uploaded/files

P.S. I'm off for today, I'll ping you tomorrow

@palpinter
Copy link
Author

OK, thanks.

@palpinter
Copy link
Author

OK, the problem not with FILE_URL at all. The real problem is when I restart meteor something delete all images in:
.meteor/local/build/programs/server/ak/images
directory.
The images came from cache by the way.

@palpinter
Copy link
Author

The problem is bigger than I thought.

Steps to reproduce:
git clone https://github.com/VeliovGroup/Meteor-Files
cd Meteor-Files/demo-simplest-upload
meteor npm install
meteor

upload a file
check .meteor/local/build/programs/server/assets/app/uploads/Images directory - file exist
restart meteor
check .meteor/local/build/programs/server/assets/app/uploads/Images directory - file doesnt exist

Now what should I do. Every restart delete all uploaded files

@dr-dimitru
Copy link
Member

It's expected behaviour, that's why I asked you multiple times to check physical file existence.
Meteor rebuilds itself on dev-stage, and removes everything what not belongs to it.
Place storage folder outside of the .meteor directory, like /data/meteor/uploads/ and make sure it's writable for user used to run node/meteor command

@palpinter
Copy link
Author

OK, thank you. I'll try.

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

No branches or pull requests

2 participants