├── modman
├── Magneto_S3.xml
├── code
└── S3
│ ├── Helper
│ └── File
│ │ └── Storage
│ │ └── Database.php
│ ├── Model
│ ├── Store.php
│ ├── System
│ │ └── Config
│ │ │ └── Source
│ │ │ └── Storage
│ │ │ └── Media
│ │ │ └── Storage.php
│ └── File
│ │ └── Storage
│ │ ├── S3
│ │ └── Abstract.php
│ │ ├── Directory
│ │ └── S3.php
│ │ └── S3.php
│ └── etc
│ ├── config.xml
│ └── system.xml
├── README.md
└── s3get.php
/modman:
--------------------------------------------------------------------------------
1 | code/S3 app/code/community/Magneto/S3
2 | Magneto_S3.xml app/etc/modules/Magneto_S3.xml
3 | s3get.php s3get.php
--------------------------------------------------------------------------------
/Magneto_S3.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 | curl http://module-manager.googlecode.com/files/modman-1.1.5 > modman 13 | chmod +x modman 14 | sudo mv modman /usr/bin 15 |16 | - set "Allow Symlinks" under System / Configuration > Advanced / Developer > Template Settings in Magento 17 | - Install via modman (for details consult modman website): 18 |
19 | cd23 | - Make sure you've cleaned Magento's cache to enable the new module 24 | - The extension configuration is under System / Configuration > Advanced / System > Storage Configuration for Media 25 | - Change "Media Storage" to S3, enter your Amazon S3 credentials 26 | 27 | ### Via Magento Connect 28 | It's not there yet... 29 | 30 | ## FEATURES 31 | - store Magento's media files on Amazon S3 32 | - works with category images, catalog products' images, thumbnails, CMS images, concatenated JS and CSS files 33 | 34 | ## KNOWN ISSUES 35 | We're working to correct these: 36 | 37 | - Changing File Storage back to "Filesystem" doesn't work yet 38 | - Not completely tested 39 | - Right now, the "Amazon S3" storage overrides "Database" storage -------------------------------------------------------------------------------- /code/S3/etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 |20 | modman init 21 | modman magneto-s3 clone https://github.com/sstoiana/magneto-s3.git 22 |
Magento supports PHP 5.2.0 or newer. Find out how to install Magento using PHP-CGI as a work-around.
'; 33 | exit; 34 | } 35 | $start = microtime(true); 36 | /** 37 | * Error reporting 38 | */ 39 | error_reporting(E_ALL | E_STRICT); 40 | ini_set('display_errors', 1); 41 | 42 | $ds = DIRECTORY_SEPARATOR; 43 | $ps = PATH_SEPARATOR; 44 | $bp = dirname(__FILE__); 45 | 46 | /** 47 | * Set include path 48 | */ 49 | 50 | $paths[] = $bp . $ds . 'app' . $ds . 'code' . $ds . 'local'; 51 | $paths[] = $bp . $ds . 'app' . $ds . 'code' . $ds . 'community'; 52 | $paths[] = $bp . $ds . 'app' . $ds . 'code' . $ds . 'core'; 53 | $paths[] = $bp . $ds . 'lib'; 54 | 55 | $appPath = implode($ps, $paths); 56 | set_include_path($appPath . $ps . get_include_path()); 57 | 58 | include_once 'Mage/Core/functions.php'; 59 | include_once 'Varien/Autoload.php'; 60 | 61 | Varien_Autoload::register(); 62 | 63 | $varDirectory = $bp . $ds . Mage_Core_Model_Config_Options::VAR_DIRECTORY; 64 | 65 | $configCacheFile = $varDirectory . $ds . 'resource_config.json'; 66 | 67 | $mediaDirectory = null; 68 | $allowedResources = array(); 69 | 70 | if (file_exists($configCacheFile) && is_readable($configCacheFile)) { 71 | $config = json_decode(file_get_contents($configCacheFile), true); 72 | 73 | //checking update time 74 | if (filemtime($configCacheFile) + $config['update_time'] > time()) { 75 | $mediaDirectory = trim(str_replace($bp . $ds, '', $config['media_directory']), $ds); 76 | $allowedResources = array_merge($allowedResources, $config['allowed_resources']); 77 | } 78 | } 79 | 80 | $request = new Zend_Controller_Request_Http(); 81 | 82 | $pathInfo = str_replace('..', '', ltrim($request->getPathInfo(), '/')); 83 | 84 | $filePath = str_replace('/', $ds, rtrim($bp, $ds) . $ds . $pathInfo); 85 | 86 | if ($mediaDirectory) { 87 | if (0 !== stripos($pathInfo, $mediaDirectory . '/')) { 88 | sendNotFoundPage(); 89 | } 90 | 91 | $relativeFilename = str_replace($mediaDirectory . '/', '', $pathInfo); 92 | checkResource($relativeFilename, $allowedResources); 93 | sendFile($filePath); 94 | } 95 | 96 | $mageFilename = 'app/Mage.php'; 97 | 98 | if (!file_exists($mageFilename)) { 99 | echo $mageFilename . ' was not found'; 100 | } 101 | 102 | require_once $mageFilename; 103 | 104 | umask(0); 105 | 106 | /* Store or website code */ 107 | $mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : ''; 108 | 109 | /* Run store or run website */ 110 | $mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store'; 111 | 112 | //if (empty($mediaDirectory)) { 113 | Mage::init($mageRunCode, $mageRunType); 114 | //} else { 115 | // Mage::init($mageRunCode, $mageRunType, array(), array('Mage_Core')); 116 | //} 117 | 118 | if (!$mediaDirectory) { 119 | $config = Mage_Core_Model_File_Storage::getScriptConfig(); 120 | $mediaDirectory = str_replace($bp . $ds, '', $config['media_directory']); 121 | $allowedResources = array_merge($allowedResources, $config['allowed_resources']); 122 | 123 | $relativeFilename = str_replace($mediaDirectory . '/', '', $pathInfo); 124 | 125 | $fp = fopen($configCacheFile, 'w'); 126 | if (flock($fp, LOCK_EX | LOCK_NB)) { 127 | ftruncate($fp, 0); 128 | fwrite($fp, json_encode($config)); 129 | } 130 | flock($fp, LOCK_UN); 131 | fclose($fp); 132 | 133 | checkResource($relativeFilename, $allowedResources); 134 | } 135 | 136 | if (0 !== stripos($pathInfo, $mediaDirectory . '/')) { 137 | sendNotFoundPage(); 138 | } 139 | 140 | $databaseFileSotrage = Mage::getModel('core/file_storage_database'); 141 | $databaseFileSotrage->loadByFilename($relativeFilename); 142 | 143 | if ($databaseFileSotrage->getId()) { 144 | $directory = dirname($filePath); 145 | if (!is_dir($directory)) { 146 | mkdir($directory, 0777, true); 147 | } 148 | 149 | $fp = fopen($filePath, 'w'); 150 | if (flock($fp, LOCK_EX | LOCK_NB)) { 151 | ftruncate($fp, 0); 152 | fwrite($fp, $databaseFileSotrage->getContent()); 153 | } 154 | flock($fp, LOCK_UN); 155 | fclose($fp); 156 | } 157 | 158 | sendFile($filePath); 159 | sendNotFoundPage(); 160 | 161 | /** 162 | * Send 404 163 | */ 164 | function sendNotFoundPage() 165 | { 166 | header('HTTP/1.0 404 Not Found'); 167 | exit; 168 | } 169 | 170 | /** 171 | * Check resource by whitelist 172 | * 173 | * @param string $resource 174 | * @param array $allowedResources 175 | */ 176 | function checkResource($resource, array $allowedResources) 177 | { 178 | $isResourceAllowed = false; 179 | foreach ($allowedResources as $allowedResource) { 180 | if (0 === stripos($resource, $allowedResource)) { 181 | $isResourceAllowed = true; 182 | } 183 | } 184 | 185 | if (!$isResourceAllowed) { 186 | sendNotFoundPage(); 187 | } 188 | } 189 | /** 190 | * Send file to browser 191 | * 192 | * @param string $file 193 | */ 194 | function sendFile($file) 195 | { 196 | if (file_exists($file) || is_readable($file)) { 197 | $transfer = new Varien_File_Transfer_Adapter_Http(); 198 | $transfer->send($file); 199 | exit; 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /code/S3/Model/File/Storage/Directory/S3.php: -------------------------------------------------------------------------------- 1 | 34 | */ 35 | class Magneto_S3_Model_File_Storage_Directory_S3 extends Magneto_S3_Model_File_Storage_S3_Abstract 36 | { 37 | /** 38 | * Prefix of model events names 39 | * 40 | * @var string 41 | */ 42 | protected $_eventPrefix = 'core_file_storage_directory_database'; 43 | 44 | /** 45 | * Collect errors during sync process 46 | * 47 | * @var array 48 | */ 49 | protected $_errors = array(); 50 | 51 | /** 52 | * Class construct 53 | * 54 | * @param string $databaseConnection 55 | */ 56 | public function __construct($connectionName = null) 57 | { 58 | Mage::log(__METHOD__); 59 | $this->_init('core/file_storage_directory_database'); 60 | 61 | parent::__construct($connectionName); 62 | } 63 | 64 | /** 65 | * Load object data by path 66 | * 67 | * @param string $path 68 | * @return Mage_Core_Model_File_Storage_Directory_Database 69 | */ 70 | public function loadByPath($path) 71 | { 72 | Mage::log(__METHOD__); 73 | // /** 74 | // * Clear model data 75 | // * addData() is used because it's needed to clear only db storaged data 76 | // */ 77 | // $this->addData( 78 | // array( 79 | // 'directory_id' => null, 80 | // 'name' => null, 81 | // 'path' => null, 82 | // 'upload_time' => null, 83 | // 'parent_id' => null 84 | // ) 85 | // ); 86 | // 87 | // $this->_getResource()->loadByPath($this, $path); 88 | return $this; 89 | } 90 | 91 | /** 92 | * Check if there was errors during sync process 93 | * 94 | * @return bool 95 | */ 96 | public function hasErrors() 97 | { 98 | Mage::log(__METHOD__); 99 | return !empty($this->_errors); 100 | } 101 | 102 | /** 103 | * Retrieve directory parent id 104 | * 105 | * @return int 106 | */ 107 | public function getParentId() 108 | { 109 | Mage::log(__METHOD__); 110 | // if (!$this->getData('parent_id')) { 111 | // $parentId = $this->_getResource()->getParentId($this->getPath()); 112 | // if (empty($parentId)) { 113 | // $parentId = null; 114 | // } 115 | // 116 | // $this->setData('parent_id', $parentId); 117 | // } 118 | // 119 | // return $parentId; 120 | return $this; 121 | } 122 | 123 | /** 124 | * Create directories recursively 125 | * 126 | * @param string $path 127 | * @return Mage_Core_Model_File_Storage_Directory_Database 128 | */ 129 | public function createRecursive($path) 130 | { 131 | $path = str_replace(array('//', '\\'), '/', $path . DS ); 132 | Mage::log(__METHOD__ . ' ' . $path); 133 | 134 | $this->_s3->putObject($this->_bucket . DS . $path, '' ); 135 | // $directory = Mage::getModel('core/file_storage_directory_database')->loadByPath($path); 136 | // 137 | // if (!$directory->getId()) { 138 | // $dirName = basename($path); 139 | // $dirPath = dirname($path); 140 | // 141 | // if ($dirPath != '.') { 142 | // $parentDir = $this->createRecursive($dirPath); 143 | // $parentId = $parentDir->getId(); 144 | // } else { 145 | // $dirPath = ''; 146 | // $parentId = null; 147 | // } 148 | // 149 | // $directory->setName($dirName); 150 | // $directory->setPath($dirPath); 151 | // $directory->setParentId($parentId); 152 | // $directory->save(); 153 | // } 154 | // 155 | // return $directory; 156 | 157 | return $this; 158 | } 159 | 160 | /** 161 | * Export directories from storage 162 | * 163 | * @param int $offset 164 | * @param int $count 165 | * @return bool 166 | */ 167 | public function exportDirectories($offset = 0, $count = 100) 168 | { 169 | Mage::log(__METHOD__); 170 | $offset = ((int) $offset >= 0) ? (int) $offset : 0; 171 | $count = ((int) $count >= 1) ? (int) $count : 1; 172 | 173 | $result = $this->_getResource()->exportDirectories($offset, $count); 174 | 175 | if (empty($result)) { 176 | return false; 177 | } 178 | 179 | return $result; 180 | } 181 | 182 | /** 183 | * Import directories to storage 184 | * 185 | * @param array $dirs 186 | * @return Mage_Core_Model_File_Storage_Directory_Database 187 | */ 188 | public function importDirectories($dirs) 189 | { 190 | Mage::log(__METHOD__); 191 | // if (!is_array($dirs)) { 192 | // return $this; 193 | // } 194 | // 195 | // $dateSingleton = Mage::getSingleton('core/date'); 196 | // foreach ($dirs as $dir) { 197 | // if (!is_array($dir) || !isset($dir['name']) || !strlen($dir['name'])) { 198 | // continue; 199 | // } 200 | // 201 | // try { 202 | // $directory = Mage::getModel( 203 | // 'core/file_storage_directory_database', 204 | // array('connection' => $this->getConnectionName()) 205 | // ); 206 | // $directory->setPath($dir['path']); 207 | // 208 | // $parentId = $directory->getParentId(); 209 | // if ($parentId || $dir['path'] == '') { 210 | // $directory->setName($dir['name']); 211 | // $directory->setUploadTime($dateSingleton->date()); 212 | // $directory->save(); 213 | // } else { 214 | // Mage::throwException(Mage::helper('core')->__('Parent directory does not exist: %s', $dir['path'])); 215 | // } 216 | // } catch (Exception $e) { 217 | // Mage::logException($e); 218 | // } 219 | // } 220 | 221 | return $this; 222 | } 223 | 224 | /** 225 | * Clean directories at storage 226 | * 227 | * @return Mage_Core_Model_File_Storage_Directory_Database 228 | */ 229 | public function clearDirectories() 230 | { 231 | Mage::log(__METHOD__); 232 | //$this->_getResource()->clearDirectories(); 233 | return $this; 234 | } 235 | 236 | /** 237 | * Return subdirectories 238 | * 239 | * @param string $directory 240 | * @return mixed 241 | */ 242 | public function getSubdirectories($directory) 243 | { 244 | Mage::log(__METHOD__ . ' ' . $directory); 245 | 246 | $directory = str_replace(array('//', '\\'), '/', $directory . DS); 247 | Mage::log(__METHOD__ . ' ' . $directory); 248 | 249 | $directory = Mage::helper('core/file_storage_database')->getMediaRelativePath($directory); 250 | Mage::log(__METHOD__ . ' ' . $directory); 251 | 252 | $response = $this->_s3->_makeRequest('GET', $this->_bucket, array('prefix'=>$directory, 'delimiter'=>'/')); 253 | 254 | if ($response->getStatus() != 200) { 255 | return false; 256 | } 257 | 258 | $xml = new SimpleXMLElement($response->getBody()); 259 | 260 | $return = array(); 261 | 262 | if (isset($xml->CommonPrefixes)) { 263 | foreach ($xml->CommonPrefixes as $file) { 264 | 265 | $file = (string)$file->Prefix; 266 | 267 | 268 | //skip non-directories 269 | // if(substr($file, -1, 1) != '/') continue; 270 | $file = substr($file, strlen($directory), -1); 271 | $return[] = array( 272 | 'name' => $file, 273 | ); 274 | } 275 | } 276 | 277 | return $return; 278 | } 279 | 280 | /** 281 | * Delete directory from database 282 | * 283 | * @param string $path 284 | * @return Mage_Core_Model_File_Storage_Directory_Database 285 | */ 286 | public function deleteDirectory($dirPath) 287 | { 288 | Mage::log(__METHOD__ . ' ' . $dirPath); 289 | 290 | $files = $this->_s3->getObjectsByBucket($this->_bucket, array('prefix'=>$dirPath)); 291 | 292 | foreach($files as $file) 293 | { 294 | Mage::log(__METHOD__ . ' delete ' . $file); 295 | $files = $this->_s3->removeObject($this->_bucket.DS.$file); 296 | } 297 | 298 | return $this; 299 | } 300 | } 301 | -------------------------------------------------------------------------------- /code/S3/Model/File/Storage/S3.php: -------------------------------------------------------------------------------- 1 | 34 | */ 35 | class Magneto_S3_Model_File_Storage_S3 extends Magneto_S3_Model_File_Storage_S3_Abstract 36 | { 37 | /** 38 | * Prefix of model events names 39 | * 40 | * @var string 41 | */ 42 | protected $_eventPrefix = 'core_file_storage_database'; 43 | 44 | 45 | /** 46 | * Collect errors during sync process 47 | * 48 | * @var array 49 | */ 50 | protected $_errors = array(); 51 | 52 | /** 53 | * Class construct 54 | * 55 | * @param string $connectionName 56 | */ 57 | public function __construct($connectionName = null) 58 | { 59 | Mage::log(__METHOD__); 60 | 61 | $this->_init('core/file_storage_database'); 62 | 63 | parent::__construct($connectionName); 64 | 65 | 66 | 67 | 68 | } 69 | 70 | /** 71 | * Create tables for file and directory storages 72 | * 73 | * @return Mage_Core_Model_File_Storage_Database 74 | */ 75 | public function init() 76 | { 77 | Mage::log(__METHOD__); 78 | return $this; 79 | } 80 | 81 | /** 82 | * Return storage name 83 | * 84 | * @return string 85 | */ 86 | public function getStorageName() 87 | { 88 | Mage::log(__METHOD__); 89 | //TODO: replace dummy 90 | return Mage::helper('core')->__('S3 bucket "%s"', $this->getConnectionName()); 91 | //return Mage::helper('core')->__('database "%s"', $this->getConnectionName()); 92 | } 93 | 94 | /** 95 | * Load object data by filename 96 | * 97 | * @param string $filePath 98 | * @return Mage_Core_Model_File_Storage_Database 99 | */ 100 | public function loadByFilename($filePath) 101 | { 102 | $filePath = str_replace(array('//', '\\'), '/', $filePath); 103 | Mage::log(__METHOD__.' '.$filePath); 104 | 105 | $_content = $this->_s3->getObject($this->_bucket . DS . $filePath); 106 | 107 | $this->setFilename(basename($filePath)); 108 | $this->setDirectory(dirname($filePath)); 109 | $this->setContent( $_content ); 110 | $this->setId($_content); 111 | 112 | return $this; 113 | } 114 | 115 | /** 116 | * Check if there was errors during sync process 117 | * 118 | * @return bool 119 | */ 120 | public function hasErrors() 121 | { 122 | Mage::log(__METHOD__); 123 | return (!empty($this->_errors)); 124 | } 125 | 126 | /** 127 | * Clear files and directories in storage 128 | * 129 | * @return Mage_Core_Model_File_Storage_Database 130 | */ 131 | public function clear() 132 | { 133 | Mage::log(__METHOD__); 134 | // $this->getDirectoryModel()->clearDirectories(); 135 | // $this->_getResource()->clearFiles(); 136 | $this->_s3->cleanBucket($this->_bucket); 137 | return $this; 138 | } 139 | 140 | /** 141 | * Export directories from storage 142 | * 143 | * @param int $offset 144 | * @param int $count 145 | * @return bool|array 146 | */ 147 | public function exportDirectories($offset = 0, $count = 100) 148 | { 149 | 150 | Mage::log(__METHOD__); 151 | 152 | //return $this->getDirectoryModel()->exportDirectories($offset, $count); 153 | // TODO: write me 154 | return false; 155 | } 156 | 157 | /** 158 | * Import directories to storage 159 | * 160 | * @param array $dirs 161 | * @return Mage_Core_Model_File_Storage_Directory_Database 162 | */ 163 | public function importDirectories($dirs) 164 | { 165 | 166 | Mage::log(__METHOD__); 167 | 168 | //no need to do anything here, since s3 doesn't know about directories 169 | return $this; 170 | } 171 | 172 | /** 173 | * Export files list in defined range 174 | * 175 | * @param int $offset 176 | * @param int $count 177 | * @return array|bool 178 | */ 179 | public function exportFiles($offset = 0, $count = 100) 180 | { 181 | 182 | Mage::log(__METHOD__); 183 | 184 | //TODO: write me 185 | return false; 186 | 187 | $offset = ((int) $offset >= 0) ? (int) $offset : 0; 188 | $count = ((int) $count >= 1) ? (int) $count : 1; 189 | 190 | $result = $this->_getResource()->getFiles($offset, $count); 191 | if (empty($result)) { 192 | return false; 193 | } 194 | 195 | return $result; 196 | } 197 | 198 | /** 199 | * Import files list 200 | * 201 | * @param array $files 202 | * @return Mage_Core_Model_File_Storage_Database 203 | */ 204 | public function importFiles($files) 205 | { 206 | 207 | Mage::log(__METHOD__); 208 | if (!is_array($files)) { 209 | return $this; 210 | } 211 | 212 | foreach ($files as $file) { 213 | if (!isset($file['filename']) || !strlen($file['filename']) || !isset($file['content'])) { 214 | continue; 215 | } 216 | 217 | try { 218 | 219 | $this->saveFile($file['directory'].DS.$file['filename']); 220 | } catch (Exception $e) { 221 | $this->_errors[] = $e->getMessage(); 222 | Mage::logException($e); 223 | } 224 | } 225 | 226 | return $this; 227 | } 228 | 229 | /** 230 | * Store file into database 231 | * 232 | * @param string $filename 233 | * @return Mage_Core_Model_File_Storage_Database 234 | */ 235 | public function saveFile($filename) 236 | { 237 | 238 | $filename = str_replace(array('//', '\\'), '/', $filename); 239 | Mage::log(__METHOD__.' '.$filename); 240 | $fileInfo = $this->collectFileInfo($filename); 241 | $filePath = $fileInfo['directory']; 242 | 243 | 244 | $this->_s3->putObject($this->_bucket . DS . $fileInfo['directory'] . DS . $fileInfo['filename'], $fileInfo['content']); 245 | 246 | return $this; 247 | } 248 | 249 | /** 250 | * Check whether file exists in DB 251 | * 252 | * @param string $filePath 253 | * @return bool 254 | */ 255 | public function fileExists($filePath) 256 | { 257 | 258 | Mage::log(__METHOD__.' '.$filePath); 259 | return $this->_s3->isObjectAvailable($this->_bucket.DS.$filePath); 260 | } 261 | 262 | /** 263 | * Copy files 264 | * 265 | * @param string $oldFilePath 266 | * @param string $newFilePath 267 | * @return Mage_Core_Model_File_Storage_Database 268 | */ 269 | public function copyFile($oldFilePath, $newFilePath) 270 | { 271 | 272 | Mage::log(__METHOD__); 273 | $_content = $this->_s3->getObject($this->_bucket.DS.$oldFilePath); 274 | $this->_s3->putObject($this->_bucket.DS.$newFilePath, $_content); 275 | 276 | return $this; 277 | } 278 | 279 | /** 280 | * Rename files in database 281 | * 282 | * @param string $oldFilePath 283 | * @param string $newFilePath 284 | * @return Mage_Core_Model_File_Storage_Database 285 | */ 286 | public function renameFile($oldFilePath, $newFilePath) 287 | { 288 | Mage::log(__METHOD__); 289 | 290 | $_content = $this->_s3->getObject($this->_bucket.DS.$oldFilePath); 291 | $this->_s3->putObject($this->_bucket.DS.$newFilePath, $_content); 292 | $this->_s3->removeObject($this->_bucket.DS.$oldFilePath); 293 | 294 | return $this; 295 | } 296 | 297 | /** 298 | * Return directory listing 299 | * 300 | * @param string $directory 301 | * @return mixed 302 | */ 303 | public function getDirectoryFiles($directory) 304 | { 305 | $directory = str_replace(array('//', '\\'), '/', $directory); 306 | Mage::log(__METHOD__ . ' ' . $directory); 307 | 308 | $directory = Mage::helper('core/file_storage_database')->getMediaRelativePath($directory); 309 | Mage::log(__METHOD__ . ' ' . $directory); 310 | 311 | $files = $this->_s3->getObjectsByBucket($this->_bucket, array('prefix'=>$directory)); 312 | 313 | $return = array(); 314 | foreach($files as $file) 315 | { 316 | if(substr($file, -1, 1) == '/') continue; 317 | 318 | $return[] = array( 319 | 'filename' => basename($file), 320 | 'directory'=> dirname($file), 321 | 'content' => $this->_s3->getObject($this->_bucket.DS.$file) 322 | ); 323 | } 324 | 325 | return $return; 326 | } 327 | 328 | /** 329 | * Delete file from database 330 | * 331 | * @param string $path 332 | * @return Mage_Core_Model_File_Storage_Database 333 | */ 334 | public function deleteFile($path) 335 | { 336 | Mage::log(__METHOD__ . ' ' . $path); 337 | $this->_s3->removeObject($this->_bucket.DS.$path); 338 | 339 | return $this; 340 | } 341 | 342 | public function deleteFolder($path) 343 | { 344 | Mage::getModel('core/file_storage_directory_database')->deleteDirectory($path); 345 | } 346 | } 347 | --------------------------------------------------------------------------------