2017 © Pedro Peláez
 

silverstripe-module silverstripe-cloudassets

Allows some or all of the assets folder to be located in a cloud storage container (CloudFiles, etc.)

image

markguinn/silverstripe-cloudassets

Allows some or all of the assets folder to be located in a cloud storage container (CloudFiles, etc.)

  • Friday, May 19, 2017
  • by markguinn
  • Repository
  • 7 Watchers
  • 18 Stars
  • 6,282 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 7 Forks
  • 12 Open issues
  • 5 Versions
  • 12 % Grown

The README.md

Cloud Assets Module

Allows you to host all or part of the assets folder on a cloud storage container (CDN)., (*1)

I would consider this beta quality software. We're using it on a couple production sites but it has not yet been widely tested across different configurations. You could experience some flakiness and may want to keep a backup of your assets initially until you've put it through it's paces, especially if not using LocalCopy mode., (*2)

Versions: Latest Stable Version Latest Unstable Version, (*3)

Licence: License, (*4)

Quality: Build Status Scrutinizer Quality Score codecov.io, (*5)

Support: ![Gitter](https://badges.gitter.im/Join Chat.svg), (*6)

Requirements

Example

Assuming you have a CloudFiles container called site-uploads:, (*7)

mysite/_config/cloudassets.yml:, (*8)

---
name: assetsconfig
---
CloudAssets:
  map:
    'assets/Uploads':
      Type: RackspaceBucket
      BaseURL: 'http://yourcdnbaseurl.com/'
      Container: site-uploads
      Region: ORD
      Username: yourlogin
      ApiKey: yourkey
      LocalCopy: false

You can map multiple folders in this way or just map the whole assets folder., (*9)

How It Works

  1. CloudFileExtension is added to File.
  2. In onAfterWrite, this extension checks if anything needs to be synced to the cloud or changed to a wrapped class.
  3. File and Image records are converted at that stage to the corresponding wrapped versions. Additional wrapper classes can be added (if you have other subclasses of File) via CloudAssets.wrappers. Note that any subclass that is not wrapped will continue to function normally and will not use the cloud.
  4. Once wrapped, the file length will be checked every onAfterWrite. If the file on disk has been replaced it will be uploaded to the cloud storage and the local version truncated to the string 'CloudFile' (see CloudAssets.file_placeholder config). NOTE: this behaviour can be changed with the LocalCopy key in the bucket config. If that is true, the file will be kept in tact locally and the modification time will be used to keep the cloud version in sync.
  5. For files (image, etc) the wrapped class overrides Link, URL, etc to point to the CDN version of the file.

This setup allows you to forgo mounting the cloud storage via s3fs, CloudFuse, etc but shouldn't require changes to the Silverstripe file subsystem., (*10)

Scenarios Where This Won't Work

  • Hosting with no writable storage. The assets folder does not need to be permanent but it does need to be used. Per-request permanence should be enough, though maybe not ideal.

Developer(s)

Contributions welcome by pull request and/or bug report. Please follow Silverstripe code standards (tests would be nice)., (*11)

I would love for someone to implement some other drivers - S3, Swift, Google, etc. It's very easy to implement drivers - just extend CloudBucket and implement a few methods., (*12)

License (MIT)

Copyright (c) 2014 Mark Guinn, (*13)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:, (*14)

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software., (*15)

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE., (*16)

The Versions

19/05 2017

dev-master

9999999-dev

Allows some or all of the assets folder to be located in a cloud storage container (CloudFiles, etc.)

  Sources   Download

MIT

The Requires

 

cdn assets silverstripe rackspace cloudfiles cloud storage

17/07 2015

dev-compat-3.0

dev-compat-3.0

Allows some or all of the assets folder to be located in a cloud storage container (CloudFiles, etc.)

  Sources   Download

MIT

The Requires

 

cdn assets silverstripe rackspace cloudfiles cloud storage

17/10 2014

1.1.0

1.1.0.0

Allows some or all of the assets folder to be located in a cloud storage container (CloudFiles, etc.)

  Sources   Download

MIT

The Requires

 

cdn assets silverstripe rackspace cloudfiles cloud storage

06/06 2014

1.0.1

1.0.1.0

Allows some or all of the assets folder to be located in a cloud storage container (CloudFiles, etc.)

  Sources   Download

MIT

The Requires

 

cdn assets silverstripe rackspace cloudfiles cloud storage

03/03 2014

1.0.0

1.0.0.0

Allows some or all of the assets folder to be located in a cloud storage container (CloudFiles, etc.)

  Sources   Download

MIT

The Requires

 

cdn assets silverstripe rackspace cloudfiles cloud storage