Answer the question
In order to leave comments, you need to log in
Storing files on a remote server?
Sorry if this is a stupid question..
There is a site - a kind of video stock. Users will upload a lot of videos.
It is necessary to implement the possibility of uploading these videos somewhere to a third-party server (hardly a cloud), at the first stage it is rather just another computer ("file server").
How is saving to such a server implemented? Well, the reverse operation, of course, should also be.
If you recommend any article about it - it will be good.
I just implemented everything on local storages for the time being, but here I needed a remote one.
Answer the question
In order to leave comments, you need to log in
If the files are less than 1.5GB, then the easiest way is to put the files on the second server with http-POST, save the path to this file in the database, and give the user a direct link to the file on the second server via http.
Well, that is, something like this:
0) there are 2 servers that respond to domain.tld and http://files1.domain.tld, respectively.
1) when uploading a file, an http-post is made to, for example, http://files1.domain.tld/upload/something-to-tam, where something-to-tam = unique file identifier in the database (random name or something like that).
2) when requesting this file from the main site, the user is given a link to http://files1.domain.tld/something(possible with protection against hot-linking'a, as a primitive protection against direct file download). On the second server, only bare nginx with the upload module
can be installed . You can do all this through PHP, however.
Just put the upload script on the server with your videos, refer to it, connect the same database to it as to the site itself.
Everyone has their own rake for this ..
Personally, for me, the entire upload goes to the main server, and the file ones pull the file for themselves.
For me, this method is better because I can load balance between file servers. At the moment there are 5 of them. If there is free space for everyone and the channel is not clogged, the file is taken by the first one who picked it up. Etc...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question