Hi, I'm trying to upload an image to a S3 bucket. In a controller, a method called uploadPhoto() gets the uploaded file and copies to a local directory:
public function uploadPhoto(Filesystem $filesystem){
$uploadedFile = Input::file('photo');
$uploadedFile->move("/tmp", "test-photo.jpg");
//...copy image to S3
}
How is the way to move the file from the temporary folder to the S3 bucket?
Does Filesystem manage this stuff?
Thanks for your answers.
Hey @jfranc014 what version of Laravel are you using?
Version 5 handles S3 (almost) out of the box. If you take a look at the docs for the filesystem service, with the appropriate package (league/flysystem-aws-s3-v2 ~1.0) this will be handled for you!
If you're using Version 4.x, you can still import and use flysystem, you'll just need to write the code to upload the files yourself.
@deringer. Sure i was working with S3 in L5, though i didn't remember that i could work with a local (to get the contents of the uploaded file) an a cloud filesystem (S3, to put these contents) at the same time with the Illuminate\Contracts\Filesystem\Factory. However the approach by @lukaskorl solved directly the issue.
Thanks for your answers!