I've finally gotten to testing external file storage systems in my project and I'm encountering a strange error when I try to analyze some of these files.
What I'm trying to achieve: Grab a list of all the files in a certain s3 directory (done) and analyze them by their ID3 tags using a php package:
https://packagist.org/packages/james-heinrich/getid3
$files = Storage::disk('s3')->files('going/down/to/the/bargin/basement/because/the/bargin/basement/is/cool'); //Get Files
$file = Storage::disk('s3')->url($files[0]); // First things first... let's grab the first one.
$getid3 = new getID3; // NEW OBJECT!
return $getid3->analyze($file); // analyze the file!
However when I throw that into tinker it squawks back at me with:
"GETID3_VERSION" => "1.9.14-201703261440",
"error" => [
"Could not open "https://a.us-east-2.amazonaws.com/library/pending/admin/01%20-%20Cathedrals.mp3" (!is_readable; !is_file; !file_exists)",
],
Which seems to indicate that the file is not readable? This is my first time utilizing AWS S3 so there may be something I haven't configured correctly.
The problem is that you are passing URL to analyze
method. This is mentioned here.
To analyze remote files over HTTP or FTP you need to copy the file locally first before running getID3()
Ideally, you will save the file from your URL locally and then pass to getID3->analyze()
// save your file from URL ($file)
// I assume $filePath is the local path to the file
$getID3 = new getID3;
return $getID3->analyze($filePath); // $filePath should be local file path and not a remote URL
To save an s3 file locally
$contents = $exists = Storage::disk('s3')->get('file.jpg');
$tmpfname = tempnam("/tmp", "FOO");
file_put_contents($tmpfname, $contents);
$getID3 = new getID3;
// now use $tmpfname for getID3
$getID3->analyze($tmpfname);
// you can delete temporary file when done