Category : laravel-filesystem

What I have done When I researched about storing files in laravel. I came across two approaches. Storing the assets directly inside the public folder. Creating a symbolic link from public/storage to storage/app/public When I researched about which one two use, I came across this stack overflow link. 👉 Difference between storing files in public ..

Read more

I wanna copy or move a directory to a new directory in laravel but the copyDirectory function always return false to me. Am I doing anything wrong with my code? Thanks in advance $destinationDir = ‘storage/Components/’.’Compressor’.’/’.$approvedRequest[‘compressor_model’].’/’; $success = File::copyDirectory(public_path().$approvedRequest[‘attachment_dir’], public_path().$destinationDir,true); $compressorUpdate->attachment_dir = $destinationDir; Sourc..

Read more

I’m trying to upload an image in laravel and I’m using store method to save it in storage. $path = $request->file(‘avatar’)->store(‘public/avatar’); It’s working fine and save the file into storage/app/public/avatar/ directory and its path will be somethin like this: public/avatar/o4C4pTNuot8dDmAjpATPn5ZJWMkbfhdKJGF5PEmw.jpg And that’s ok! but I have a problem with retrieving this image! when I try ..

Read more

Problem Statement: I am wondering if it is possible in Laravel 8 to move a stored file from one folder to another within AWS. Exception has occurred. GuzzleHttpExceptionClientException: Client error: `HEAD https://bucket-name.s3.us-east-2.amazonaws.com/case/9/609260ae9803b_1620205742/file.pdf` resulted in a `404 Not Found` response Code Snippet Storage::disk(‘s3’)->move( /temp/file.pdf, /case/9/file.pdf ); If Yes, then can help to do the same? Happy ..

Read more

Problem Statement: I am wondering if it is possible in Laravel 8 to move or copy a stored file from one directory to another within AWS. I tried below code but it is giving me following error. /temp/file.pdf => /case/9/file.pdf Exception Exception has occurred. GuzzleHttpExceptionClientException: Client error: `HEAD https://bucket-name.s3.us-east-2.amazonaws.com/case/9/file.pdf` resulted in a `404 Not Found` ..

Read more

Problem Statement: I am wondering if it is possible in Laravel 8 to move or copy a stored file from one directory to another within AWS. I tried below code but it is giving me following error. /temp/file.pdf => /case/9/file.pdf Exception Exception has occurred. GuzzleHttpExceptionClientException: Client error: `HEAD https://bucket-name.s3.us-east-2.amazonaws.com/case/9/file.pdf` resulted in a `404 Not Found` ..

Read more

Hi everyone I stuck on Digital Ocean that I want to prevent my file from the public. First of all. I set the .env file like this DO_SPACES_KEY= THE KEY DO_SPACES_SECRET= THE SECRET DO_SPACES_ENDPOINT=https://sgp1.digitaloceanspaces.com DO_SPACES_REGION=sgp1 DO_SPACES_BUCKET= MY BUCKET NAME DO_SPACES_URL=https://mydomain.sgp1.digitaloceanspaces.com Then I set the config->filesystem.php ‘do_spaces’ => [ ‘driver’ => ‘s3’, ‘key’ => env(‘DO_SPACES_KEY’), ‘secret’ ..

Read more

So as the title said, I’m struggling to copy a folder to another folder I tried this but no results public function copyFolder(Request $request) { $id= $request->get(‘oldf’); $new = $request->get(‘newf’); $document = Document::find($id); $newk = Document::find($new); $npath = $newk->url; $file= new Filesystem(); if($file->copyDirectory($document->url, $npath)){ return redirect(‘home’); } return redirect(‘home’); } any help would be appreciated ..

Read more

I’m using unisharp file manager and I have a problem: my Image files are in different dimensions, some are square, some other are rectangular. I want to save thumbnails with original dimensions but the lfm config uses a static width and height size choice for thumbs: ‘thumb_img_width’ => 200, // px ‘thumb_img_height’ => 200, // ..

Read more

I use a custom local disk: ‘brand_pdf’ => [ ‘driver’ => ‘local’, ‘root’ => storage_path(‘app/public/brand_pdf’), ‘url’ => env(‘APP_URL’) . ‘/storage/brand_pdf’, ‘visibility’ => ‘public’, ], In the database the file path saved in pdf column, e.g. placeholder.pdf. In the model in fields method: File::make(‘Description’, ‘pdf’)->disk(‘brand_pdf’), I’ve created a symlink by php artisan storage:link. I can upload ..

Read more

How can I get AWS S3 image as streaming view? Now I can see image as following url: <img src="https://s3.us-east-1.amazonaws.com/my-bucket/image.png" /> I want to get like this: <img src="https://myproject.com/upload/image.png" /> I tried as following but it didn’t work. My route: Route::get(‘/upload/{path_to_image}’, ‘[email protected]’)->where(‘path’, ‘(.*)’); -My Controller public function getImage($disk, $path) { $headers = array( ‘Content-Type: application/image’, ..

Read more