Skip to:
Content
Pages
Categories
Search
Top
Bottom

sync uploads folder across multiple servers

  • Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    Using a CDN (Cloud Files) for album and avatars.
    Album works fine.

    Avatars, when uploaded, appear in the correct folder. Example: /avatars/9/test-sc.jpg
    And appears in the browser, ready for cropping.
    But after cropping, the folder is deleted.
    After cropping, the browser message is ‘Your new avatar was uploaded successfully!’
    So… !?.

    Any hints on where the upload and resize/crop code is?
    Or how that process works?
    I’ve looked in bp-core-template.php

Viewing 8 replies - 1 through 8 (of 8 total)
  • Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    We were using a symlink – but it doesn’t support renaming files.
    So we went with a every 1 minute cronjob instead.

    The reason for all this was trying to keep the uploads folder synced across multiple servers.
    So image processing will stay on server X, cronjob will pull all files to CDN, and all display calls will be routed to CDN.

    Avatar of Brandon Allen
    Brandon Allen
    Participant

    @cnorris23

    The avatar code is in bp-core/bp-core-avatars.php.

    Avatar of Virtuali
    Virtuali
    Participant

    @gunju2221

    The cropping is jquery, so I would look for the avatar files with the label “.js”

    Avatar of Brandon Allen
    Brandon Allen
    Participant

    @cnorris23

    There aren’t any avatar js files. The avatar code is output in the section of the html. The bp-core/bp-core-avatars.php file handles the actual cropping and saving of avatar files.

    Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    The cronjob approach didn’t work either.

    So, the basic issue is still trying to keep the uploads folder synced across multiple servers.

    If anyone has encountered this, please advise.

    Rackspace server support is now suggesting
    -local replication with rsync with persistence on the load balancer
    or
    -NFS (real-time synchronization)

    The crop code is a bit hidden, but after upload, it stores the image somewhere in wp-uploads. After the crop, it deletes that original and saves the crop. If I get time at work, I’ll look up the path (you could just view the img src for an avatar that has been uploaded.

    The easiest way I see would be sync directories across the servers, but that’s not without its own issues (sounds like you’ve found some of them). We did have a plugin somewhere that put avatars onto S3; that would be the approach I might take in this situation. I’m not sure if that plugin was ever released publicly.

    Avatar of shanebpdev
    shanebp
    Participant

    @shanebp

    This is all new to me, but I think what is happening is that all file uploads are sent to CDN (Cloud Files). But BP does file operations (copying and creating thumbs, etc), on the file in the uploads dir, but the new files are not uploaded to CDN. The original file is deleted as it should be but on a display call the avatar shown is the default avatar because the call looks in CDN for a file that was never uploaded.

    One approach might be to do the operations and then, in bp-core-avatars.php, upload to CDN.
    But this isn’t just about avatars, it’s everything in the uploads folder.
    So any subsequent operations would require getting the file from CDN rather than uploads, doing operations and then putting it back into the CDN. Not sure if this would work and if it did wouldn’t it waste bandwidth and increase time significantly.

    Paul – any info you have re avatars to S3 would be appreciated, especially re GD operations on avatars.

    Items other than avatars are likely not to do with WordPress, so it may be worth broadening your search efforts to look for multisite-specific techniques. As far as I can tell, the s3 avatar upload code was never released publically (or if it was, I can’t find it)

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

You must be logged in to reply to this topic.