/**
  * Create a temporary file
  *
  * Call this method to create a new file. To add new chunks, use PUT on /artifact_temporary_files/:id
  *
  * <p>Limitations:</p>
  * <pre>
  * * Size of each chunk cannot exceed 1MB<br>
  * * Total size of temporary files cannot exceed a given quota. Default is 64MB, but it depends on the settings of <br>
  * &nbsp; your platform. See X-QUOTA and X-DISK-USAGE custom headers to know the quota and your usage.
  * </pre>
  *
  * @url POST
  * @param string $name          Name of the file {@from body}
  * @param string $mimetype      Mime-Type of the file {@from body}
  * @param string $content       First chunk of the file (base64-encoded) {@from body}
  * @param string $description   Description of the file {@from body}
  *
  * @return \Tuleap\Tracker\REST\Artifact\FileInfoRepresentation
  * @throws 500 406 403
  */
 protected function post($name, $mimetype, $content, $description = null)
 {
     try {
         $this->file_manager->validateChunkSize($this->user, $content);
         $file = $this->file_manager->save($this->user, $name, $description, $mimetype);
         $chunk_offset = 1;
         $append = $this->file_manager->appendChunk($content, $file, $chunk_offset);
     } catch (CannotCreateException $e) {
         $this->raiseError(500);
     } catch (ChunkTooBigException $e) {
         $this->raiseError(406, 'Uploaded content exceeds maximum size of ' . $this->file_manager->getMaximumChunkSize());
     } catch (InvalidPathException $e) {
         $this->raiseError(500, $e->getMessage());
     } catch (QuotaExceededException $e) {
         $this->raiseError(406, 'You exceeded your quota. Please remove existing temporary files before continuing.');
     }
     if (!$append) {
         $this->raiseError(500);
     }
     $this->sendAllowHeadersForArtifactFiles();
     return $this->buildFileRepresentation($file);
 }
 /**
  * Create a temporary file
  *
  * Call this method to create a new file. To add new chunks, use PUT on /artifact_temporary_files/:id
  *
  * @url POST
  * @param string $name          Name of the file {@from body}
  * @param string $mimetype      Mime-Type of the file {@from body}
  * @param string $content       First chunk of the file (base64-encoded) {@from body}
  * @param string $description   Description of the file {@from body}
  *
  * @return \Tuleap\Tracker\REST\Artifact\FileInfoRepresentation
  * @throws 500 406 403
  */
 protected function post($name, $mimetype, $content, $description = null)
 {
     $this->sendAllowHeadersForArtifactFiles();
     try {
         $this->file_manager->validateChunkSize($content);
         $file = $this->file_manager->save($name, $description, $mimetype);
         $chunk_offset = 1;
         $append = $this->file_manager->appendChunk($content, $file, $chunk_offset);
     } catch (CannotCreateException $e) {
         throw new RestException(500);
     } catch (ChunkTooBigException $e) {
         throw new RestException(406, 'Uploaded content exceeds maximum size of ' . FileManager::getMaximumChunkSize());
     } catch (TemporaryFileTooBigException $e) {
         throw new RestException(406, "Temporary file's content exceeds maximum size of " . FileManager::getMaximumTemporaryFileSize());
     } catch (InvalidPathException $e) {
         throw new RestException(500, $e->getMessage());
     } catch (MaxFilesException $e) {
         throw new RestException(403, 'Maximum number of temporary files reached: ' . FileManager::TEMP_FILE_NB_MAX);
     }
     if (!$append) {
         throw new RestException(500);
     }
     return $this->buildFileRepresentation($file);
 }