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.)
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.