Meteor - Copy files to public

I have a directory at the same level as ‘client’, ‘server’, ‘public’, and I would like to copy files from this directory to the ‘public’ directory.

Is it possible ? And if so how to achieve this operation do?
Should a special package be used?
Is there a tutorial?
I need your help.

Thank you for your answers

Hello !

What is it that you are trying to achieve ? Why do you have to copy files in public folder and have them too in another folder ? Have you tried simply putting them directly in public ? (I’m not sure you can import from the public folder but you can try I guess it will work ! :D).

But to copy files I think the simplest way is the filesystem api (this is directly in nodejs) !

const fs = require(‘fs’);

And then you can do actions on the filesystem like copying files and other stuff !

Hope it helps!

Ok, I thought I had this kind of question …
My directory contains a very large amount of files, (images, very large text, road map etc)
These documents are used by javascript scripts that refer to these files, referenced as if they were in ‘public’ directory.
If I put this directory under public, the simplest, the server meteor generates a lot of errors and ultimately does not start.
I do not know what meteor does with ‘public’, but it seems that too many files cause problems.

So I think to store these files in a directory on the server, and transfer the files concerned by a script to execute in public directory, before loading this script. Once loaded, the srcipt will find its files in public.
Another benefit is of course, that I do not load anything at the opening of the application.

If you have a criticism of this method or another solution, I stay tuned.
Thank you for your interest in my problem
(Exuse English, I am French and use a translation software to help me ask my questions)

Weird, so Meteor crashes from too many files in the public folder? I thought public was just supposed to be a basic dumb file server.

So you have a client script that requires files from the public folder, and now you want to make a server script that listens to messages from the client and then moves files back and forth between folders in time for the client to access them? Sounds complicated.

Maybe try hosting the files with CollectionFS instead?

Yes, I think it’s going to be quite complicated.
Before launching, I would like to elucidate this problem of meteor crash.
The error is:

=> Started proxy.
throw error;

RangeError: Invalid array buffer length
at new ArrayBuffer (native)
at new Uint8Array (native)

Have you ever been confronted with this problem?
I will continue my research.
If anyone has the solution, I listen.

How many files are in the public folder when it crashes ? Are you sure it is because of the number of files and not another (obscure maybe) reason ?

Try to know exactly how many files makes it crash and also try with other types of files (even if you create two thousand dummy files just to see) and if you find that it is really a problem with Meteor then maybe you should put together an example repo of the crash and submit an issue on the meteor github page with the example crashing app and more informations about your configuration !

I know I’m not helping much by saying that but if after these tests it ends up being a problem with Meteor then I see no alternative :confused:

I have an idea! If you want simple file serving without worrying about Meteor, why not use a web server like Nginx to host the files? Either on a different port, or by setting up nGinx as a reverse proxy and redirecting based on path.

310 files, 19 directories, 1,4Go
If I add a file (image for example) meteor crash !!!
I reduced the project to its minimum. Just after the meteor create I add the directory ‘public’ and insert my files.
If I start meteor, meteor will crash.
I posted an issue on the meteor github page. I await their reply.

I just tried throwing some crap in my public folder to see what happened.
3561 files, 2.1 GiB
My computer slowed down to a crawl, Meteor took forever to build, and Node apparantly stores the entire public folder in RAM. It didn’t crash though, runs fine!
What OS are you running? I’ve had some issues with Meteor and Windows, so I switched to Linux.

I’m using windows 10 pro 64 bits
I always shrug off the moment I decided to switch to linux, but I think the time has come to do it.
I will however wait for meteor’s reply.

You tell me that meteor loads the entire public folder into RAM. This is a real problem because in a classic navigation 3/4 of the public resources are not used. In addition, the loading time of the application must be increased.
I will consider the design of my application.

Yeah I think either Mac or Linux is safest if you’re going to work with Meteor a lot. I had a bunch of random build issues and stuff on Windows. It was the last OS to get official support and there are probably not many people at MDG that are enthusiastic about it.