• Resolved Anonymous User 14004806

    (@anonymized-14004806)


    Hi,

    I’m trying to upload .rar file but I get an error. (ZIP files work good) The file exists and permissions are correct.

    “Error offloading /var/www/server/wp-content/uploads/2021/09/xg_Pack_1.2.rar to provider: Found 1 error while validating the input provided for the PutObject operation: [ContentType] must be a string or an object that implements __toString(). Found bool(false)”

    Uploading like this:

    global $as3cf;
    $upl = $as3cf->upload_attachment($attachment->ID);
    function my_theme_custom_upload_mimes( $existing_mimes ) { // allow rar uploads
            $existing_mimes['rar'] = 'application/rar';
            $existing_mimes['scs'] = 'application/zip';
            $existing_mimes['package'] = 'application/octet-stream';
            return $existing_mimes;
        }
         add_filter( 'upload_mimes', 'my_theme_custom_upload_mimes', 99);
        add_filter( 'as3cf_allowed_mime_types', 'my_theme_custom_upload_mimes', 101);
    • This topic was modified 4 years, 8 months ago by Anonymous User 14004806.
    • This topic was modified 4 years, 8 months ago by Anonymous User 14004806.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Delicious Brains

    (@deliciousbrains)

    I think the problem is because WP still doesn’t know what those new extension’s mime types are, and so can’t provide proper mime type info to be set on the object header.

    Instead of implementing the 'upload_mimes' filter, implement 'mime_types', that way WP knows about the new mime types and will allow them to be uploaded too.

    It’s probably only worth implementing 'upload_mimes' if you want to remove a mime type from the allowed types, usually based on the given $user.

    If you’re using the 'mime_types' filter then you’ll not need to implement the 'as3cf_allowed_mime_types' filter too, unless you do implement the 'upload_mimes' filter to disable some direct uploads to the Media Library but still want to offload the type that enters the Media Library some other way.

    -IJ

    Thread Starter Anonymous User 14004806

    (@anonymized-14004806)

    Hi,

    Thanks for reply. It was working fine before, no idea what happened and why it’s not working now. Added mime_types filter, no changes.

    EDIT: if I remove .rar from allowed mimes, I get “Mime type application/rar is not allowed”.

    Regards,
    Rob.

    • This reply was modified 4 years, 8 months ago by Anonymous User 14004806.
    Thread Starter Anonymous User 14004806

    (@anonymized-14004806)

    Problem solved. FILEINFO_MIME_TYPE in wp_check_filetype_and_ext was returning “application/x-rar”.

    Plugin Author Delicious Brains

    (@deliciousbrains)

    Neat, glad you found a fix.

    -IJ

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Found 1 error while validating the input provided for the PutObject operation’ is closed to new replies.