How to keep file sync'd in OpenShift?

后端 未结 3 459
面向向阳花
面向向阳花 2021-02-10 19:43

For OpenShift:

I created a test directory in ~ app-root/repo/data. I also have locally \'myapp\'/data directory. I can push up to OpenShift wi

3条回答
  •  遥遥无期
    2021-02-10 20:10

    Check this blog: https://community.jboss.org/people/ozizka/blog/2013/01/06/openshift--how-to-make-uploaded-files-public

    OpenShift applications code is uploaded using Git. Any changes in the repository directory is recreated after push. Therefore, storing uploaded files in there won't work.

    The only persistent directory you can use is ../data. It's full path is stored in environment variable $OPENSHIFT_DATA_DIR. However, this dir is not public - so no URL leads there.

    The solution is quite easy - just create a symlink. Here's an example for PHP. Login to your machine via SSH, and run:

    mkdir app-root/data/photos
    cd app-root/repo/php    #  php/ is the only publicly accessible directory (by default, not sure if not changeable in .htaccess).
    ln -s ../../data/photos photos
    

    This makes the content in ../data/photos publicly accessible at http://myapp-myaccount.rhcloud.com/photos/ . The directory to manage the files in can be referred to using $_ENV['OPENSHIFT_DATA_DIR'].

提交回复
热议问题