Question

I have uploaded file to Spaces using Laravel (but the file split into multi-part object), how to Get Filename after uploaded to Spaces?

I have uploaded >50MB single mp4 file to Spaces using Laravel, then I look at my bucket and see the storage usage is increased, but the file I’ve been uploaded doesn’t exist in control panel. I look at the docs and notice:

If you have a large number of objects or multi-part uploads, you may not be able to view all your objects in the control panel. You can still view all the objects using the Spaces API and s3-compatible tools such as s3cmd or AWS S3.

I try to view all my objects in Spaces with this line of code but it doesn’t show that uploaded file (but any other objects which appears in control panel, are appeared in this too):

$files = Storage::allFiles($directory);

dd($files);

I’m stuck and I assume that my file has been uploaded and split into multi-part objects. The problem is, I need to know the filename (of the uploaded file, not original filename) to save it to the database. I used to do this before:

//Validate request
$validatedData = $request->validate([
                 ...
                 "video_trailer" => "required"
                 ]);


//Upload to Spaces
$validatedData["video_trailer"] = Storage::put(
            "video-trailer",
            $request->file("video_trailer")
            );


//Insert into Database
DBname::create($validatedData);

But when I dump and die the $validatedData[“video_trailer”] is return FALSE, and then when I look at the database table, the value of column video_trailer is 0. So how to get the filename of the uploaded file? or there is any alternative solution for that (like try to upload to Spaces in different ways)? or did I do something wrong?. Sorry for bad english, I’m new in Spaces and S3, and I’ll be Thank You so much if you helping me.


Submit an answer
Answer a question...

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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Jeff Braunstein
DigitalOcean Employee
DigitalOcean Employee badge
January 10, 2023

Hi there, I wonder if there was a problem during the file upload and the entire file didn’t get uploaded? Can you test it again with a small file (<1MB)?

Bobby Iliev
Site Moderator
Site Moderator badge
January 10, 2023

Hi there,

Usually I use this approach here with the league/flysystem-aws-s3-v3 package and the following works for me:

Storage::disk('digitalocean')->putFile('uploads', request()->file, 'public');

Can you share the code snippet you are using for uploading the files so I can try to replicate this on my end as well?

Do you see any errors in your log that might indicate that the file isn’t uploaded successfully?

Best,

Bobby