I am currently working on a Laravel project for API and a VueJS project for the front end. My main objective is to efficiently upload large video files to the server with minimal chances of failure. I have explored two different methods for achieving this.
Method 1 - Using resumablejs:
this.r = new Resumable({
target:process.env.API_URL+'upload',
query:{upload_token:'my_token'},
headers:{
Authorization: 'Bearer '
},
maxChunkRetries: 1,
simultaneousUploads: 1,
testChunks: false,
});
// Code snippet continues...
Method 2 - Creating manual chunk:
upload() {
const url = 'upload'
this.$axios.post(url, this.formData).then(() => {
this.chunks.shift()
}).catch((error) => {
})
},
createChunks() {
// Code snippet continues...
}
Both approaches yield similar results on the backend. The next step involves merging the chunk files into one final file. In my Laravel code, I have implemented the following-
public function upload(Request $request)
{
$file = $request->file('file');
Storage::disk('local')->append('output/' . $file->getClientOriginalName(), $file->get());
}
However, I am encountering an issue with the output generated using this approach. Although the input and output file sizes match, the resulting video file is not playable in its entirety. It plays only the initial few seconds before stopping abruptly. This issue is not present when dealing with PDF files. What could be causing this problem specifically with video files?