/** * Determine the Content-Type of the file */ protected function guessContentType() { return Mimetypes::getInstance()->fromFilename($this->filename) ?: 'application/octet-stream'; }
/** * @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()); } }