5

So, we have built a file uploader in our application that is working on the local environment. We have the files being uploaded to public/upload and we can read the files using:

http://localhost:3000/upload/filename.extension

Now, when we move the code to production, we use a check:

getUploadPath = function () {
    var fs = Npm.require('fs');
    var path = Npm.require('path');
    var devPath = path.join(process.cwd(),"../../../../../public");
    var prodPath = path.join(process.cwd(),"../client/app/");
    if (fs.existsSync(devPath)) {
        return path.join(devPath,"upload");
    } 
    else {
        return path.join(prodPath,"upload");
    }
}

Now, this saves the file to {prod_path}/programs/client/app/upload. However, I cannot use the file in the application. What's surprising is all the files that were in local seem to also be present in the same upload folder and are accessible by the application. What am I missing ?

4

1 回答 1

0

如果此应用程序在 Nginx 或 Apache 的服务器上运行,您可以设置 /upload 位置,因此文件将直接在没有 Meteor 的情况下提供。

在 Nginx 上,我使用这样的东西:

location /upload/ {
    root /home/app-name/bundle/programs/web.browser/app;
}
于 2014-12-21T00:47:49.757 回答