Ejemplo n.º 1
0
 /**
  * Determine the Content-Type of the file
  */
 protected function guessContentType()
 {
     return Mimetypes::getInstance()->fromFilename($this->filename) ?: 'application/octet-stream';
 }
Ejemplo n.º 2
0
 /**
  * @return bool
  */
 public function stream_flush()
 {
     if ($this->mode == 'r') {
         return false;
     }
     $this->body->rewind();
     $params = $this->params;
     $params['Body'] = $this->body;
     // Attempt to guess the ContentType of the upload based on the
     // file extension of the key
     if (!isset($params['ContentType']) && ($type = Mimetypes::getInstance()->fromFilename($params['Key']))) {
         $params['ContentType'] = $type;
     }
     try {
         self::$client->putObject($params);
         return true;
     } catch (\Exception $e) {
         return $this->triggerError($e->getMessage());
     }
 }