Localhost da çalışan bu kodlar Sunucuya gittiğin de 100 mb üzeri dosyalar da bu şekilde hataya sebep oluyor. Uzun zamandır çözümünü bulamadım. Local de çalışıp da neden sunucuya geçince böyle bir hata verir ki ?
return Plupload::file('file', function ($file) {
try {
$path = Storage::disk('s3')->putFile('medias', $file);
$cmd = Storage::disk('s3')
->getDriver()
->getAdapter()
->getClient()
->getCommand('GetObject', [
'Bucket' => config("filesystems.disks.s3.bucket"),
'Key' => $path,
]);
$link = Storage::disk('s3')
->getDriver()
->getAdapter()
->getClient()
->createPresignedRequest($cmd, '+12 hours')
->getUri();
$linkSave=(string) $link;
$token = config('services.cloudflare.token');
$accountId = config('services.cloudflare.acountId');
$client = new Client();
//file upload
/*
$response = $client->request('POST', 'https://api.cloudflare.com/client/v4/accounts/' . $accountId . '/stream', [
'headers' => [
'Authorization' => 'Bearer ' . $token,
],
'multipart' => [
[
'name' => 'file',
'contents' => fopen($file, 'r+'),
'filename' => $file->getClientOriginalName(),
],
]
]);*/
//link upload
$response = $client->request('POST', 'https://api.cloudflare.com/client/v4/accounts/' . $accountId . '/stream/copy', [
'headers' => [
'Authorization' => 'Bearer ' . $token,
'Content-Type' => 'application/json',
],
'json' => [
"url" => $linkSave,
"meta" => [
"name" => $file->getClientOriginalName()
]
]
]);
$data = json_decode($response->getBody(), true); // returns an array
$path = null;
foreach ($data as $key => $dat) {
if (is_array($dat) && array_key_exists('preview', $dat)) {
$path = $dat['preview'];
}
}
$videoUrl = str_replace('watch', 'iframe', $path);
$videoPath = '<iframe src="' . $videoUrl . '" style="border: none; position: absolute; top: 0; left: 0; height: 100%; width: 100%;" allow="accelerometer; gyroscope; autoplay; encrypted-media; picture-in-picture;" allowfullscreen="true" id="stream-player"></iframe>';
$media = Media::create([
'name' => $file->getClientOriginalName(),
'path' => $videoPath,
'extension' => $file->getClientOriginalExtension(),
'user_id' => auth()->user()->id,
]);
return [
'success' => true,
'message' => 'Upload successful.',
];
} catch (\Exception $exception) {
return [
'success' => false,
'message' => 'Upload error.',
];
}