Comments (34)
MeteorFiles.remove({})
removes record from MongoDB andunlink
file from FS (removes file physically)MeteorFiles.collection.remove({})
just removes record from MongoDB- You can allow
.remove()
from client viaallowClientCode
flag passed into Constructor - Our deploy system is very simple, but server's structure is complicated
- The nodejs apps is powered by Phusion Passenger + Nginx and behind proxy gate (for load balancing an durability)
Deploy scheme:
On your local machine (assuming you app called: myapp
)
# in meteor's app folder
meteor build ../ --architecture os.linux.x86_64
rsync -auhiP -e 'ssh -p 22' ../myapp.tar.gz ostrio@SERVER_IP:/home/user/
On server:
# go to directory with transferred archive
cd /home/user
# Unpack archive
tar -xvf myapp.tar.gz
rm myapp.tar.gz
# Block below will allow to serve static files via nginx
# we set server's root in nginx config to /var/www/myapp/public
mkdir -p ./bundle/public
cp ./bundle/programs/web.browser/*.css ./bundle/public/
cp ./bundle/programs/web.browser/*.js ./bundle/public/
cp -R ./bundle/programs/web.browser/app/* ./bundle/public/
# change to your user
chown -R user:usergroup ./bundle
cd ./bundle/programs/server
# install npm dependencies as your user
su -s /bin/bash -c 'npm install --production' user
# install extra dependencies if needed
# su -s /bin/bash -c 'npm install [email protected] [email protected] --production --save' user
cd ../../../
# Remove old compiled JSs and CSSs
rm -Rf /var/www/myapp/programs/web.browser/*
rm /var/www/myapp/public/*.js /var/www/myapp/public/*.css
# Update project's files
rsync -azuhiP ./bundle/ /var/www/myapp
# Fix permissions
chown -R user:usergroup /var/www/myapp
chmod -R 744 /var/www/myapp
chmod 755 /var/www/myapp
chmod -R 755 /var/www/myapp/public
passenger-config restart-app /var/www/myapp
# Show status
passenger-status -v
# Show logs
tail -n 100 -f /var/log/nginx/error.log
- Do not forget to change
SERVER_IP
,user:usergroup
,myapp
and path to project on server (we used/var/www
) to your values - You can omit/change part with passenger, for example to
god
,forever
, etc.
from meteor-files.
Make sure you aren't overwriting folder where files is stored on deploy.
I recommend to use rsync
with -azuiP
flags.
And currently I won't recommend to use relative path to user. I'm emphatically recommend to always use absolute path. Or at least left default value for storagePath
to see if it's working properly.
from meteor-files.
then i would have to rsync to my local machine everytime I push code to the server, and when I forget once, the data would be overwritten?
or do i missunderstand?
from meteor-files.
Can't clearly answer as I don't now your server's structure and how it's configured, and I've never worked with MUP/MUPX
- You don't need to sync your server with local machine (unless you want to keep all uploaded files locally)
- If
storagePath
is out of your Meteor/NodeJS directory uploaded files shouldn't be overwritten - Have you tried to use package's default
storagePath
? - Have you tried to use absolute value for
storagePath
?
from meteor-files.
i have tried storagePath: '/tmp/UploadedFiles'
, no storagePath
and
storagePath: '~/tmp/meteor/imgs'
.
I am running an Ubuntu 14.04.4 x64
droplet on digitalOcean
from meteor-files.
- Do you able to obtain uploaded files in those directories?
- Do you upload compiled app (NodeJS) or as "Meteor App"?
from meteor-files.
- what do you mean by this?
- mupx writes this:
Deploy app 'anna_app' (linux)
to the console when they start to deploy. so i assume its "Meteor App". but any images that i have locally do not get uploaded
from meteor-files.
- Can you go to
/tmp/UploadedFiles
on you server andls -la
to see uploaded files - Yes, MUPX won't deploy anything what is not related to application codebase - this is expected behaviour
Deploy you application, and then upload files
from meteor-files.
- the tmp folder at
/opt/anna_app/tmp
contains nothing butbundle.tar.gz
. and/tmp
is empty.
from meteor-files.
Do you have any error/warning at server's console?
Meteor-Files should warn you if storagePath
is not writable/accessible
from meteor-files.
i can upload. see the portfolio page
the image you see is uploaded via the package.
the current storagePath
is '/tmp/UploadedFiles'
i have no warnings.
from meteor-files.
I guess your server just wiping out /tmp
folder frequently, as it's basically temporary folder
from meteor-files.
but the files are still online.
from meteor-files.
Sorry, but I did't get you.
- What is not working right now?
from meteor-files.
when i do mupx deploy
again, all the files are gone.
so everytime I make a change to the code, i have to reupload all the projects.
from meteor-files.
probably mupx builds app inside /tmp/
and probably wipes out tmp folder after build, try to use /data/UploadedFiles
from meteor-files.
with storagePath: '/data/UploadedFiles'
the files still go missing after deploy.
and another thing happened a couple of times now - when uploading an image, onUploaded
never gets called. the upload just stops at a 100%.
most of the times onUploaded
gets called and everything works. but when this happens. i have to reset the whole project.
from meteor-files.
- Could you please post your server's logs, as this error clearly says what
path must be a string
- Could you please post more of your code, where this package is used?
from meteor-files.
'change #file-input': function (e, t) {
var project = this._id;
var advance = true;
var r = 0;
var files = e.currentTarget.files;
function insert(file, rank) {
log('insert');
t.currentFile.set(Images.insert({
file: file,
meta: {rank: rank, project: project, big: false},
onUploaded: function (error, fileObj) {
log('onUploaded');
if (error) {
console.log(error);
return false;
} else {
Projects.update({_id: project}, {$push: {imgs: fileObj._id}}, function (err, s) {
if (err) {
console.log('Projects.update Error: ' + err);
// return false;
} else {
console.log('Projects updated: ' + s);
t.currentFile.set(false);
advance = true;
}
});
}
}
}));
}
function loop() {
if (advance == false) {
setTimeout(function () {
loop()
}, 500);
} else {
advance = false;
insert(files[r], r);
r++;
if (r < files.length) {
loop()
}
}
}
loop();
}
i had to set it up this way to allow for multiple imgs to be uploaded with one action. when I had just passed the images in without this loop()
, advance
and timeout
architecture, it called Projects.update
just once and added only one the last image to the project.
what logs do you need?
from meteor-files.
Logs from your server's console
from meteor-files.
the screenshot that i shared, those where all.
from meteor-files.
To insert multiple images use _.each
:
'change #file-input': function (e, t) {
_.each(e.currentTarget.files, function (file) {
Images.insert({/* ... */});
});
}
from meteor-files.
BTW which version of Meteor and Package are you using?
from meteor-files.
ostrio:[email protected]
meteor1.3.1
when I use _.each
, onUploaded
only gets called once for the last image. and thus only the last image gets added to the projects.imgs array
from meteor-files.
- Unfortunately I can't answer why directory gets whipped out after you have deployed app via MUPX. As this question is not related to Meteor-Files package directly, please address this question to Meteor-UP team
- About multiple file upload - I'll provide an expressive example soon
- About server-side error - The
path must be a string
meansstoragePath
isn't set or not a string, to debug this:- Post here your server-side code related to this package
- Run package in debug mode (pass
debug: true
to Constructor) and post here server's logs
from meteor-files.
- ok i'll ask them and when we find out what it is, i will tell you.
Images = new Meteor.Files({
collectionName: 'Images',
storagePath: '/data/UploadedFiles',
debug: true
});
uploading the code right now. logs follow
from meteor-files.
ok, so i looked at the logs and saw that this issue always occurred after i had deleted a file from the Images
collection.
I rewrote the .remove
function to be a serverside method
. now the issue stopped occurring. one question about that. Images.remove
vs Images.collection.remove
- whats the difference?
about the "images go missing after using mupx deploy
- there are others with the same issue.
but i need a quick solution. how do you deploy your applications? i'll just use your way…
from meteor-files.
ok so i just spent the last three days to get your package to work in my configuration and i cant get it done.
i teach this stuff to myself and this is too much.
i will need to find a different package to host images. sry
from meteor-files.
this thread clearly explains why your FS is changing on every deploy
from meteor-files.
This is clearly a mup/mupx deploy issue since there is no volume mounted that persists your data in the docker container, so this has nothing to do with this package. I am copying a backup of all the files uploaded by ostrio:files to the newly deployed instance after deployment and that solves the issue for now.
BUT for CI reasons if you directly want to deploy from Jenkins/Travis to your server then I can see the issue. For this, you would have to write your own script at the moment, and also the copying of the files takes time.
I think currently you would have to fork the meteor-up project and add the volume to the container creation routine and then if it is good make a pull request to have this functionality. Because currently I can't see a ticket for it (https://github.com/kadirahq/meteor-up/issues) in the active repository of meteor-up on github (https://github.com/kadirahq/meteor-up).
from meteor-files.
@FinnFrotscher could we close this issue?
from meteor-files.
yes. i am now using S3.
from meteor-files.
@FinnFrotscher with this package of CFS?
from meteor-files.
@dr-dimitru no, directly via their API
from meteor-files.
Related Issues (20)
- ENOENT: no such file or directory, mkdir HOT 18
- onBeforeUpload and other functions should be able to be asynchronous HOT 1
- Custom Endpoint for MinIO ? HOT 2
- What defines the filename of the saved file? HOT 2
- Async support HOT 23
- [FilesCollection.ServiceFile] Path "/assets/app/uploads/ServiceFileCollection" is not writable! HOT 2
- How to change item metadata before it is inserted into the collection? HOT 9
- How do I update a filesCollection after Server side Write created? HOT 1
- Get user ip on upload HOT 9
- Since Meteor 2.11 - Exception in setTimeout callback: TypeError: fs.remove is not a function HOT 9
- Question: Can you store directly in GridFS? HOT 2
- Question: Save link in database?
- Update aws-sdk to v3 in 'Use AWS:S3 As Storage' Documentation HOT 4
- Files.load -> options.fileName is not in filepath HOT 2
- FilesCollection.find(...).each() not working properly? HOT 1
- HTTP uploads not working, multi-instance/cluster environment NGINX balanced HOT 5
- onAfterUpload not throwing error in uploader.on('end') HOT 5
- Cannot stream a video with filenames longer than 80 characters HOT 1
- wrong custom error message when using HTTP
- Make Meteor-Files compatible with meteor-desktop? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-files.