probably not copying to both. More likely you have a symlink in place
Jan 14, 2022
3
Level 2
Upload to Digital ocean spaces copies files to public folder
My method for uploading files to digital ocean spaces works perfectly but the files are uploaded both in project's public folder and spaces directory. I want to only upload files to digital ocean spaces and keep none in the project directory how can I go about this??
here is how my upload function looks like
if ($file = $request->hasFile('display_image')) {
$post_image = $request->file('display_image');
$filename = $post_image->getClientOriginalName();
$compressed_image = $this->compressImage($post_image, $filename);
$path = Storage::putFileAs('uploads/displayimage/'.$post->post_id, $compressed_image, 'public', 'spaces');
$post->display_image = $filename;
}
here is my file system configuration
'spaces' => [
'driver' => 's3',
'key' => env('SPACES_ACCESS_KEY_ID'),
'secret' => env('SPACES_SECRET_ACCESS_KEY'),
'region' => env('SPACES_DEFAULT_REGION'),
'bucket' => env('SPACES_BUCKET'),
'endpoint' => env('SPACES_ENDPOINT'),
'url' => env('SPACES_URL'),
'visibility' => 'public'
]
Please or to participate in this conversation.