Jun 17, 2020
0
Level 7
Storage putFile 504 error
I am uploading a large file to S3 and getting a 504 Gateway Timeout error returned to me. That confusing part is the file does indeed still upload, but on the frontend after a bit I get the 504 error? I am streaming the file so I thought this would prevent burning resources?
Here is the full code:
public function store(Request $request)
{
$request->validate([
'email' => 'required|email',
'video' => 'required',
]);
if ($request->hasFile('video')) {
//Upload original file
$original_key = Storage::putFile(
'originals',
new File($request->file('video')),
['Content-Disposition' => 'attachment']
);
//Convert file for preview
$config = [
'PresetId' => '1351620000001-100070',
'width' => 1920,
'height' => 1080,
'aspect' => '16:9',
'ext' => 'mp4',
'PipelineId' => env('PIPELINE_ID'),
];
$elastcoder = new ElastcoderAWS();
$original_array = explode('/', $original_key);
$preview_key = end($original_array);
$thumbPattern = "thumbnails/{$preview_key}-{count}";
$job = $elastcoder->transcodeVideo($original_key, $preview_key, $config, $thumbPattern);
$submission = new Submission();
$submission->email = $request->input('email');
$submission->original = config('filesystems.disks.s3.url') . $original_key;
$submission->preview = config('filesystems.disks.s3.url') . $preview_key;
$submission->thumbnail = config('filesystems.disks.s3.url') . "thumbnails/{$preview_key}-00001.png";
$submission->transcoding_id = $job["Id"];
$submission->save();
return response()->json([
'submission' => $submission,
'message' => 'Video Upload. Good Luck!!!'
]);
} else {
return response()->json([
'submission' => false,
'message' => 'Upload Error. Please try again later.'
]);
}
}
Please or to participate in this conversation.