Hi guys,
I am developing a rather complex file system in Laravel, and I have some high requirements to achieve. I was wondering which solution is the best for maintenance and scalability.
Requirements include support for partial uploads, no filesize limit and the uploaded file has to be trackable by database in the future.
- Via a custom API, obtain an upload hash for a file and post file parts to an endpoint using the hash as a reference
Pros:
- Supports partial uploads.
- Ignore server
post_max_size
as the file can be consolidated into one big file if needed. - User can switch networks during the upload without losing progress.
- Fast upload speeds.
Cons:
- Difficult to track the byte ranges during the upload process.
- 2 Database queries per part upload, one for getting the file by reference, and 2nd for getting the uploaded byte ranges using another table.
- Heavy resource usage on the server.
- Directly upload parts belonging to the same file, and one file at a time.
Pros:
- Supports partial uploads.
- Ignore server
post_max_size
limit as the file can be consolidated into one big file if needed. - Current uploading file hash can be stored in session instead of the database
- Less programming effort on tracking byte ranges
Cons:
- Slower upload as multiple files cannot be uploaded at once.
- User cannot switch network during the upload.
- Just post the file along with form submissions, the traditional way.
Pros:
- Super easy to code.
- Much less resource usage on the server as the file upload succeeds with the form post.
- No need to keep track of byte ranges.
Cons:
- Subject to absolute
post_max_size
limits. - Does not support partial upload
- Slow form submissions
- Does not support ajax
The project is hosting on a premium hosting so free hosting limits do not apply. Which one should I go with? Thanks.
- Method 1
- Method 2
- Method 3
Feel free to suggest more methods if I didn’t cover them.
Cheers!