| 1 |
= sfAmazonS3FS - transparent use of Amazon S3 for your local file system = |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
'''What it is''' |
|---|
| 5 |
Abstracts the Amazon Simple Storage Service(S3) allowing you to treat S3 |
|---|
| 6 |
like a local file system. Using a cache you get the speed of the local FS |
|---|
| 7 |
with the reliability of S3. This works on distributed systems and clusters |
|---|
| 8 |
as S3 will act as the master file system while the local machine maintains |
|---|
| 9 |
a cache. |
|---|
| 10 |
|
|---|
| 11 |
'''The sfAmazonS3File object''' |
|---|
| 12 |
An sfAmazonS3File object should be thought of as a typical file on your |
|---|
| 13 |
local file system not as an S3 object. When instantiated if the file exists |
|---|
| 14 |
on S3 and not on the local file system it will be copied to the local FS. |
|---|
| 15 |
Any actions after that will use the cached file. |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
'''Features:''' |
|---|
| 19 |
- Maintains cache of files locally |
|---|
| 20 |
- Put / Get / Delete files in S3 is totally transparent |
|---|
| 21 |
- Get file data, file path, or escaped url |
|---|
| 22 |
- Get files from request and put them in S3 |
|---|
| 23 |
|
|---|
| 24 |
'''Planned Features:''' |
|---|
| 25 |
- Zip files for S3 |
|---|
| 26 |
- Make file additions atomic (if it fails adding to S3 don't put in cache) |
|---|
| 27 |
|
|---|
| 28 |
'''Installation''' |
|---|
| 29 |
app.yml.dist - copy contents to app.yml and add your amazon keys and select |
|---|
| 30 |
a default bucket where your files will be stored. You can override these |
|---|
| 31 |
settings by passing the constructor the keys and bucket info if you prefer |
|---|
| 32 |
|
|---|
| 33 |
config.php.dist - copy contents to config.php. This file controls where |
|---|
| 34 |
files will be stored locally. By default they are put in: |
|---|
| 35 |
web/uploads/sfAmazonS3FS. To make sure web/uploads is writable run: |
|---|
| 36 |
'symfony fix-perms' |
|---|
| 37 |
|
|---|
| 38 |
pear install Crypt_HMAC |
|---|
| 39 |
pear install HTTP_Request |
|---|
| 40 |
|
|---|
| 41 |
'''Dependencies''' |
|---|
| 42 |
Pear Packages |
|---|
| 43 |
- Crypt_HMAC |
|---|
| 44 |
- HTTP_Request |
|---|
| 45 |
- pecl/Fileinfo |
|---|
| 46 |
|
|---|
| 47 |
'''Exmaples:''' |
|---|
| 48 |
|
|---|
| 49 |
//Create a file from a form submission |
|---|
| 50 |
{{{ |
|---|
| 51 |
$fileName = '/you/can/have/many/subfolders/file.txt'; |
|---|
| 52 |
sfAmazonS3File::getNewInstance($fileName)->addFromRequest('agent_photo'); |
|---|
| 53 |
}}} |
|---|
| 54 |
|
|---|
| 55 |
//Retrieve a file |
|---|
| 56 |
{{{ |
|---|
| 57 |
$fileName = '/you/can/have/many/subfolders/file.txt'; |
|---|
| 58 |
$f = sfAmazonS3File::getNewInstance($fileName); |
|---|
| 59 |
echo $f->getURL(); // URL to file |
|---|
| 60 |
echo $f->getPath(); // Absolute path to local file |
|---|
| 61 |
}}} |
|---|
| 62 |
|
|---|
| 63 |
//Delete file |
|---|
| 64 |
{{{ |
|---|
| 65 |
$fileName = '/you/can/have/many/subfolders/file.txt'; |
|---|
| 66 |
sfAmazonS3File::getNewInstance($fileName)->delete(); |
|---|
| 67 |
}}} |
|---|