I am using DigitalOcean Spaces as a configured disk in Laravel and was having a problem with deletion of file using the following codes:
Source: https://laravel.com/docs/5.5/filesystem#deleting-files
Storage::disk('spaces')->delete('foldername/'.$fileName);
I have no problem uploading photos but I wanna have an option of replacing a file when a new one is uploaded. I tried this using my local disk and it worked, but when using do_spaces disk, nothing happens. I can even check that the file exists by using Storage::disk('spaces')->exists('foldername/'.$fileName); before trying to delete.
I am not sure if this is an issue in do spaces or is delete function like above is not supported here. Any idea what I’m doing wrong? Thanks
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
The delete file storage method within Laravel does work with Digital Ocean spaces. We use it on our projects. The only thing I can think of is you are not including the full path of the file, including the extension to delete it.
Try deleting the file without the variable and see if that works. If so, it leads me to believe something is wrong with your $filename variable.
Storage::disk('do')->delete('folder/file.txt');
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.