Best methodology for file uploading (how does YouTube do it?) - file

What is the best method to follow for uploading files to server using my website? Each user will upload some files to his profile. Should I place all files in a single directory or do I need to create folders for each user and keep the files there?
How does YouTube do this? How should I store the uploaded info in database? What's the most efficient approach to do this when handling large number of users and files? I don't want to know about the usage of API. I want to know the best approach for file organization.

I would have a folder for each user, its more managable!
I wouldn't fancy a massive folder with loads of files!
You could end up with duplicate file names and end up deleting another users files!
I would create a directory for every user!

Related

How can I deal with the file which users upload?

If I have a website, and every user can upload his or her file, after I get this file, how can I deal with this file.
Should I store it to a specific folder(like upload), and store the file path in a specific database(for example table upload_file)?
Or should I just store this file in the database, if I can, how can I apply this to reality??
I think the first way is much better, but can I store all upload files in the same folder, or should I make a folder for each user?
Maybe I can encrypt the file name with md5 or anothers?
I do not know in real website development, how can you deal with the file, and keep the relationship with the user?
Thanks for your help !!
If they are small, just store it in the database;
Otherwise store they in a floder

Kentico v10 Is it possible to do a bulk export of files from the CMS media library to a folder on a PC?

We have built a file upload facility on our Kentico v10 website. External users upload documents into folders within the media library, and internal staff then need to extract these uploaded documents in order to work with them.
Is it possible to extract the documents in media library in bulk?
We have been told it is only possible to extract the files 1 at a time. There are over 500 a month being uploaded so this has been an unpopular solution with the staff who extract these documents.
It seems unlikely that Kentico would build a CMS that doesn't allow bulk exports from a media library, especially when they have a facility that allows files to be uploaded.
The link below shows a screenshot example of the problem. It is numerous files in the media library that require extracting in bulk. Currently we extract one by one.
![media library with documents requiring bulk extraction]https://drive.google.com/file/d/1lDV1sL7CEtQoVqLoawgtd8r2m7O-bPBr/view?usp=sharing!
If anyone knows a way we can extract these files in bulk to a PC, your help is very much appreciated!
Thank you
Technically speaking, all files for media library are sitting already in a folder on server, so you could get an access to the particular folder and download it (maybe via FTP)...
Or there is an export feature which you may find handy in this case:
https://blogs.jeroenfurst.nl/blog/october-2015/quick-tip-how-to-export-a-media-library-with-files
Open zip folder, extract files in export{timestamp}.zip\Data\Files\media_files##SITENAME##{LibraryFolder}{LibraryName} and change the extension from File_Name.jpg.export to File_Name.jpg
In this case, there is no way to simply export a given selection of files from the Media Library. You can use the example Michal Samuhel gave from Kentico MVP, Jeroen Furst although that exports the whole library.
Your best case would be to create a custom webpart which will allow users to filter the media library files by date, then perform an export on them. The downside, is if the media library files aren't "imported" into the media library, there is no database representation of them at all.
Another option is to modify your upload and email processing process:
users upload to a directory in the media library
you create a custom scheduled task which takes those new files, zips them up, saves the zip file to a download directory, then and sends an email with a link to download the files.
the scheduled task takes those "exported" files and relocates them to a new directory for safe keeping.

Uploading and saving files in CakePHP 2.1

I want to save my uploads in a specific folder for each app_id. For example, when an applicant with app_id of 45 uploads the files it must save in a folder named 45 whilst all his/her uploads such as birth certificate, college certificate, profile picture and high school certificate will be in that folder, same to the other app_id eg 89 must have his/her own folder but all the uploaded files will be located in one parent folder for example webroot/files/uploads/....
I managed to implement Uploader v3.6 from Miles Johnson, so any help on that plugin or any other solutions
Any tutorial or link to tackle this challenge
Thank you
A huge security fail in your idea is to store high school certificates in the public (!) accessible /webroot/files/uploads folder. You can be sure to get in pretty unpleasant situations in many countries that have privacy laws if everyone can download these proivate documents from your server.
Storing the files in folders 1, 2, 3... using the incremental ids is also a bad idea performance wise: Read the section "File System Performance" of this article.
Storing all files attached to a user in the same folder might be a good idea if you want to delete all of them in one action when you delete the user but you should not forget about sanitizing the file names properly. But again: If you store thousands of files in the same (sub) folder you might get into issues again.
For a file storage solution for CakePHP 2.x I can suggest you to read the readme.md of my FileStorage plugin that covers nearly all common problems and gives you a solid base for a file storage.

Best file permission for users to upload and delete files and folders

Lets say I let people upload files on the server. Should I change the file name s
after the upload ? if yes, how can I tell the about the file names later on , beacause in CMS I need tpo provide them with the url to images or doc files etc so they refer to them while producing text for the website.
I coded a program with which my users can navigate through some files and folders
they can create folders and upload files of any extension inside the mentioned folders
. Unfortinately my code creates all files and foldes with 777 permission. I wanna know
What would happen if someone uploads a .php file inside a folder and runs it. Can he/she
Delete every possible thing ? May you help me with right permission I should give to those files
and folders. The uploader should know about the url where he/she has uploaded
the image so while creating some content he can refer to them as url for images or
office word documents. Please help me with security hole.
Thank you.
I suggest you create some database table as a reference to those file so that you can record the old name, and changing the name in file system to different one so that you will never overwrite an existing file with same name.Or you can even same file in DB instead of file system.
First thing is you should not allow user upload any executable files to your server, or at least you need to change the extension name to something else I think. And I don't think 777 is needed, you just need to make sure the folder r/w to the php/web server processor and that's should be enough for any user access them

grails file upload

Hey. I need to upload some files (images/pdf/pp) to my SQLS Database and thereafter, download it again. I'm not sure what is the best solution - store it as bytes, or store it as file (not sure if possible). I need later to databind multiple domain classes together with that file upload.
Any help would be very much apreciated,
JM
saving files in the file system or in the DB is a general question which is asked here several times.
check this: Store images(jpg,gif,png) in filesystem or DB?
I recommend to save the files in the file system and just save the path in the DB.
(if you want to work with google app-engine though you have to save the file as byte array in the DB as saving files in the file system is not possible with google app-engine)
To upload file with grails check this: http://www.grails.org/Controllers+-+File+Uploads

Resources