最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

nginx - Laravel DigitalOcean Spaces Upload Works Locally but Fails for Large Files After Deployment - Stack Overflow

programmeradmin3浏览0评论

I am using Laravel 9 to upload files to DigitalOcean Spaces. The upload works perfectly on my local machine for both small and large files. However, after deploying to a server, it only works for small files—large files fail to upload.

Here’s my Laravel upload code:

$disk = Storage::disk('spaces');
$directory = 'media_transcription/audio/';
$fileName = uniqid() . '_' . $audioFile->getClientOriginalName();
$filePath = $directory . $fileName;

try {
    $uploaded = $disk->put($filePath, file_get_contents($audioFile), 'public');

    if ($uploaded) {
        if ($disk->exists($filePath)) {
            Log::info(' File exists in storage!', ['file_path' => $filePath]);
        } else {
            return response()->json(['error' => 'File upload verification failed.'], 500);
        }
    } else {
        return response()->json(['error' => 'File upload failed.'], 500);
    }
} catch (\Exception $e) {
    Log::error('Failed to upload file to DigitalOcean Spaces.', ['error' => $e->getMessage()]);
    return response()->json(['error' => 'File upload failed.'], 500);
}

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论