• Hello all,

    I am using wp_handle_upload and wp_insert_attachment to let my users manually upload files.

    The files correctly appear in the media library but they aren’t copied to S3 – so I assume the plugin is not called.
    Is there a way for the plugin to be called?

    Also when the files are deleted from the media library they aren’t deleted in the wp_content/uploads directory….

    thanks!

    https://wordpress.org/plugins/amazon-s3-and-cloudfront/

Viewing 5 replies - 1 through 5 (of 5 total)
  • The plugin hooks into the wp_update_attachment_metadata filter to upload to files to s3, and this filter is called by the function wp_update_attachment_metadata(), and this function is called by 12 other functions in wordpress and your wp_handle_upload() and wp_insert_attachment()
    functions are not one of them,here is the list.

    wp_restore_image()
    wp_save_image()
    wp_generate_attachment_metadata()
    media_handle_upload()
    media_handle_sideload()
    edit_post()
    wp_ajax_save_attachment()
    Custom_Image_Header::insert_attachment()
    Custom_Image_Header::step_2()
    Custom_Background::handle_upload()
    wp_maybe_generate_attachment_metadata()
    wp_xmlrpc_server::mw_newMediaObject()

    Try using any of the above relevant function for your upload and the plugin will handle the rest.

    On second thought your wp_insert_attachment() function according to the codex should be used in conjunction with wp_update_attachment_metadata() and wp_generate_attachment_metadata() functions. And both of these functions triggers the filter wp_update_attachment_metadata the plugin uses to upload files to s3 especially the wp_update_attachment_metadata() function. Please check your code to make sure it conforms with the codex, and if it is,then the plugin should handle your uploads to s3.

    Thread Starter gbourda

    (@gbourda)

    Thanks,

    I am now just calling media_handle_upload

    It takes care of everything including upload and attachments & the file is now correctly uploaded to S3.

    Thanks a lot for your help!

    I can not get this to trigger from a front-end update. My code works just fine, but the

    This is handling my upload fine:

    $attachment_id = media_handle_upload( ‘my_image_upload’, $_POST[‘post_id’] );

    But it’s AWS and S3 are not getting triggered. I’ve tried everything. I’ve had it call wp_update_attachment_metadata(), too, just for good measure.

    I’ve tried tracking this backwards but I can’t seem to locate where it goes off the rails.

    Following (sorry, forgot to hit that button)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp_handle_upload’ is closed to new replies.