• upload to S3 appears to be working, but the upload_path is not being added for the individual sites. Thus images are being uploaded to bucket/files/year/month/filename.jpg for all sites.

    I would like it to upload into the same file structure as current site so something like
    bucket/blogs.dir/siteid/files/year/month/filename.jpg or bucket/siteid/files/year/month/filename.jpg.

    I need each site’s media to be uploaded in a separate distinct folder prevent another site from overwriting another site’s files.

    My site is an older wpmu site that has been upgraded/converted to worpdress 3.5 multisite. I’m wondering if maybe there is a define missing or setting that is new in 3.5 that the plugin is looking for to update the prefix?

    any advice/help would be greatly appreciated. Thanks,
    Bob

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Any luck?

    ig_communitysites

    (@ig_communitysites)

    It looks to me as if the code for adding the site prefix to the upload path simply isn’t in the plugin any more: I can’t see that it’s even attempting to add it anywhere.

    There used to be an ‘upload_path’ method in the old Tantan S3 plugin for handling that prefix, which was called via an ‘option_siteurl’ filter, but it’s nowhere to be seen in the current code. Everything’s changed quite a lot, obviously, so it’s difficult to compare precisely…but I haven’t found any equivalent code from rummaging around. There’s a ‘get_base_upload_path’ method, but that explicitly states that it’s ‘without the multisite subdirectory’ in a comment.

    As with you, Bob, we’re upgrading from an old 3.4.1 site which has already been uploading files to an S3 bucket with prefixes for each sub-site on the network. So we can’t really do that upgrade if the functionality is just going to disappear: we need that to be consistent.

    (Scratches head.)

    ig_communitysites

    (@ig_communitysites)

    So, here’s my attempt…

    Firstly, I’ve copied the old ‘upload_path’ method from the old plugin:

    // ikg/commsites - method taken from old tantan s3 plugin to generate sub-site prefix
        // no equivalent function in the current plugin as far as I can see
        // figure out the correct path to upload to, for wordpress mu installs
        function upload_path($path='') {
            global $current_blog;
            if (!$current_blog) return $path;
            if ($current_blog->path == '/' && ($current_blog->blog_id != 1)) {
                $dir = substr($current_blog->domain, 0, strpos($current_blog->domain, '.'));
            } else {
                // prepend a directory onto the path for vhosted blogs
                if (constant("VHOST") != 'yes') {
                    $dir = '';
                } else {
                    $dir = $current_blog->path;
                }
            }
            //echo trim($path.'/'.$dir, '/');
            if ($path == '') {
                $path = $current_blog->path;
            }
            return trim($path.'/'.$dir, '/');
        }
        // ikg/commsites - ends

    …and that seems still to work all right. Then, I’ve found the new plugin code which generates the path to the file and inserted a call to that function there:

    $prefix = ltrim( trailingslashit( $this->get_setting( 'object-prefix' ) ), '/' );
            $prefix .= ltrim( trailingslashit( $this->get_dynamic_prefix( $time ) ), '/' );
            // ikg/commsites - hack to add sub-site sub-domain to the path to recreate old tantan s3 functionality
            if (is_multisite()) {
                $site_prefix = $this->upload_path();
                if ($site_prefix) {
                    $prefix = $site_prefix.'/'.$prefix;
                }
            }
            // ikg/commsites - ends

    I haven’t had a chance to fully test that yet, but it does appear that the uploaded file ends up in the right place: in a folder named after the sub-site. Not a perfect solution, I imagine, but it might at least patch things up while that functionality’s built back into the new plugin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multi-site upload url not used’ is closed to new replies.