PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, January 2, 2022

[FIXED] Laravel cant delete file in remote url using Storage::('s3')->delete($files); but can delete when using aws command

 January 02, 2022     amazon-web-services, laravel, minio, php     No comments   

Issue

I want to delete these files in my laravel like this. But it doesnt work!!

use Storage;

class SomeController extends Controller
{
    public function delete()
    {
        $filesToDelete = [
           'http://minio:9100/minio/myapp/1/ImNkE0wwrstgSpzFyruw8.jpeg',
           'http://minio:9100/minio/myapp/1/YFrdE0sarsAcpfFyrifd2.jpeg'
        ];

        // cant delete using this
        Storage::disk('s3')->delete($filesToDelete); 
    }
}

But when I try to delete using this command in my bash it works perfectly

aws --endpoint-url http://minio:9100 s3 rm s3://myapp/1/ImNkE0wwrstgSpzFyruw8.jpeg
delete: s3://myapp/1/ImNkE0wwrstgSpzFyruw8.jpeg

my aws configure list is exactly the same in my project config! I can use Storage to upload the files but when I try to delete the files it doesnt work:

// Working
Storage::disk('s3')->put('1/ImNkE0wwrstgSpzFyruw8.jpeg', $file);

Am I doing something wrong? Is there anyway to delete these files using laravel??

https://docs.min.io/docs/aws-cli-with-minio https://readouble.com/laravel/5.4/en/filesystem.html


Solution

I think the problem is file path. Try to run as mentioned below.

Storage::disk('s3')->delete('myapp/1/ImNkE0wwrstgSpzFyruw8.jpeg'); 


Answered By - Hashan
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing