function _put($options = array()) { $result = ''; $to_path = empty($options['path']) ? '' : $options['path']; $from_path = empty($options['url']) ? '' : $options['url']; if (!($to_path && $from_path)) { throw new InvalidArgumentException('Send array with url and path keys'); } // if the next character is also a slash, then we're talking an absolute path $relative = substr($to_path, 0, 1) != '/'; $mime = empty($options['mime']) ? '' : $options['mime']; if (empty($mime)) { $mime = mime_from_path($from_path); } //if (substr($to_path, 0, 1) == '/') $to_path = substr($to_path, 1); $extract = $mime == mime_from_extension('tgz'); if ($extract) { throw new RuntimeException("CoderArchiveExtension not supported with File::System"); } if (!safe_path($to_path)) { throw new RuntimeException('Could not create path: ' . $to_path); } $file = basename($from_path); if (!@rename($from_path, $to_path)) { throw new RuntimeException("Could not rename from: {$from_path} to: {$to_path}"); } if ($this->getOption('Verbose')) { $this->log("Renamed {$from_path} to {$to_path}"); } @chmod($to_path, 0777); // TODO: fix this terrible kludge that allows ftp user to delete files //@chmod(dirname($to_path), 0777); //@chmod(dirname(dirname($to_path)), 0777); }
function addMeta($path, $key, $value = '') { $result = FALSE; if ($key && $path) { $access_key_id = $this->getOption('AWSAccessKeyID'); $secret_access_key = $this->getOption('AWSSecretAccessKey'); $bucket = $this->getOption('S3Bucket'); if ($bucket && $access_key_id && $secret_access_key) { $bucket_path = $bucket . '/' . $path; $txt_mime = mime_from_extension('txt'); $a = array(); if (is_array($key)) { $a = $key; } else { $a[$key] = $value; } foreach ($a as $k => $v) { $info_file_path = meta_file_path($k, $bucket_path); $result = $info_file_path && s3_put_data($access_key_id, $secret_access_key, $info_file_path, $v, $txt_mime); if (!$result) { $this->log($info_file_path . ' ' . $access_key_id . ' ' . $secret_access_key . ' ' . $v . ' ' . $txt_mime); break; } } } } return $result; }
function mime_from_path($path) { $result = FALSE; if ($path) { $extension = strtolower(file_extension($path)); if ($extension) { $result = mime_from_extension($extension); if (!$result) { if (function_exists('mime_content_type')) { $result = @mime_content_type($path); } } if (!$result) { $result = mime_type_of_file($path); } } } return $result; }