• Third time, awesome plugin. ?? Seriously, I haven’t got it to work yet, but I can tell from your video and by going through your code, that it is. But there is, as I said in another ticket, some rough edges. Here is another one:

    I created AWS credentials for the plugin and entered it in the settings page, went to the S3 import page and started to transfer more than 700 images. The progress bar moved to the right slowly but steady, and finally it was finished. But no images in my S3 bucket! It took me a couple of minutes to realize that I forgot to assign a S3 policy to the plugins AWS credentials. Bummer.

    So this is the first problem. The plugin must check that it has enough permission. Otherwise a less experienced user may check the box delete images on upload, and not be too happy afterwards.

    Now, instead of just adding the missing permissions and redo the thing, I choose to delete the credentials and start over. Now the S3 importer got stuck on the very first image. Why I don’t know. But this is another problem. Fortunately, I had the WP debug logging enabled, so here you can see the error message produced:

    PHP Fatal error: Uncaught InvalidArgumentException: Found 2 errors while validating the input provided for the PutObject operation:
    [Key] is missing and is a required parameter
    [Key] expected string length to be >= 1, but found string length of 0 in /srv/www.kntnt.se/web/wp-content/plugins/ilab-media-tools/vendor/aws/aws-sdk-php/src/Api/Validator.php:65
    Stack trace:
    #0 /srv/www.kntnt.se/web/wp-content/plugins/ilab-media-tools/vendor/aws/aws-sdk-php/src/Middleware.php(79): ILAB_Aws\Api\Validator->validate(‘PutObject’, Object(ILAB_Aws\Api\StructureShape), Array)
    #1 /srv/www.kntnt.se/web/wp-content/plugins/ilab-media-tools/vendor/aws/aws-sdk-php/src/S3/S3Client.php(354): ILAB_Aws\Middleware::ILAB_Aws\{closure}(Object(ILAB_Aws\Command), NULL)
    #2 /srv/www.kntnt.se/web/wp-content/plugins/ilab-media-tools/vendor/aws/aws-sdk-php/src/S3/S3Client.php(377): ILAB_Aws\S3\S3Client::ILAB_Aws\S3\{closure}(Object(ILAB_Aws\Command), NULL)
    #3 /srv/www.kntnt.se/web/wp-content/plugins/ilab-media-tools/vendor/aws/aws-sdk-php/src/S3/S3Client.php(31 in /srv/www.kntnt.se/web/wp-content/plugins/ilab-media-tools/vendor/aws/aws-sdk-php/src/Api/Validator.php on line 65

    Finally, I completely uninstalled the plugin, and re-installed it again. But the same thing happened. This time I assume it is because there were some WP_Background_Process remains in the option table (see another ticket by me).

    https://www.ads-software.com/plugins/ilab-media-tools/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Thomas Barregren

    (@tbarregren)

    This is the content of $data in the failing lines:

    Array
    (
        [bitrate] => 12813162
        [filesize] => 35972999
        [mime_type] => video/quicktime
        [length] => 22
        [length_formatted] => 0:22
        [width] => 1920
        [height] => 1080
        [fileformat] => mp4
        [dataformat] => quicktime
    )
    Thread Starter Thomas Barregren

    (@tbarregren)

    SOLUTION:

    WordPress don’t store a video clip’s path in its metadata (it is still available as the attachment’s guid). That explains the bug.

    Since ILAB Media Tools only supports images, as far as I understand, it should really not process non-images (videos, pdfs, whatever). So the best solution (in my opinion) is to not to import non-images in the first place.

    I therefore modified importMedia() in classes/tools/s3/ilab-media-s3-tool.php so it looks as follows:

    public function importMedia() {
    
        $query = new WP_Query(array(
          'post_type'      => 'attachment',
          'post_status'    => 'inherit',
          'post_mime_type' =>'image',
          'fields'         => 'ids',
          'nopaging'       => true,
        ));
    
        if ($query->post_count > 0) {
            update_option('ilab_s3_import_status', true);
            update_option('ilab_s3_import_total_count', $query->post_count);
            update_option('ilab_s3_import_current', 1);
    
            $process = new ILABS3ImportProcess();
    
            for($i = 0; $i < $query->post_count; ++$i) {
                $process->push_to_queue(['index' => $i, 'post' => $query->posts[$i]]);
            }
    
            $process->save();
            $process->dispatch();
        } else {
            update_option('ilab_s3_import_status', false);
        }
    
        header('Content-type: application/json');
        echo '{"status":"running"}';
        die;
    }

    Following is a patch-file:

    --- classes/tools/s3/ilab-media-s3-tool.php	2016-08-24 10:44:24.010656014 +0200
    +++ classes/tools/s3/ilab-media-s3-tool.php	2016-08-24 10:44:03.554613353 +0200
    @@ -482,21 +482,23 @@
    
         public function importMedia() {
    
    -        $attachments = get_posts([
    -                                     'post_type'=> 'attachment',
    -                                     'posts_per_page' => -1
    -                                 ]);
    +        $query = new WP_Query(array(
    +          'post_type'      => 'attachment',
    +          'post_status'    => 'inherit',
    +          'post_mime_type' =>'image',
    +          'fields'         => 'ids',
    +          'nopaging'       => true,
    +        ));
    
    -
    -        if (count($attachments)>0) {
    +        if ($query->post_count > 0) {
                 update_option('ilab_s3_import_status', true);
    -            update_option('ilab_s3_import_total_count', count($attachments));
    +            update_option('ilab_s3_import_total_count', $query->post_count);
                 update_option('ilab_s3_import_current', 1);
    
                 $process = new ILABS3ImportProcess();
    -
    -            for($i = 0; $i<count($attachments); $i++) {
    -                $process->push_to_queue(['index' => $i, 'post' => $attachments[$i]->ID]);
    +
    +            for($i = 0; $i < $query->post_count; ++$i) {
    +                $process->push_to_queue(['index' => $i, 'post' => $query->posts[$i]]);
                 }
    
                 $process->save();

    I followed the setup completely and set up a new user and then set up the security policy for the user but I too have no images in the bucket.

    In the tutorial it says that the user has to be assigned an AWS S3 Read Only access policy. surely this then stops the upload writing to the bucket?

    Sorted it, created another user with read/write access to S3 to do the upload bit from the web server to S3, files now appearing.. the video is unclear who the user is for and this would be for the imgix side when it is reading from the server so a separate user is needed for that access to protect your files.

    and yes you do have to be careful as a newbie you don’t hit that delete from server button on the initial load to find their are now files in the bucket..

    mediegruppen

    (@mediegruppen)

    Hi

    I’m stuck with a related issue – it’s about PDF files though. When uploading a PDF file in WP Media, then it casts an error like this https://cl.ly/0z0t0A1V1n0S but the file IS actually uploaded to S3. It’s not shown immediately in the WP Media.. but after refreshing, it’s there.

    Suggestions?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘S3 importer stuck with fatal error’ is closed to new replies.