protected function createAttachmentForRest(Tracker_FileInfo $attachment, $file_info)
 {
     $path = $this->getRootPath();
     if (!is_dir($path . '/thumbnails')) {
         mkdir($path . '/thumbnails', 0777, true);
     }
     $method = 'move_uploaded_file';
     $tmp_name = $file_info['tmp_name'];
     if (isset($file_info['id'])) {
         $filename = $file_info['id'];
         $temporary = new Tracker_Artifact_Attachment_TemporaryFileManager($this->getCurrentUser(), $this->getTemporaryFileManagerDao(), $this->getFileInfoFactory());
         if (!$temporary->exists($filename)) {
             $attachment->delete();
             return false;
         }
         $method = 'rename';
         $tmp_name = $temporary->getPath($filename);
         $temporary->removeTemporaryFileInDBByTemporaryName($filename);
     }
     return $this->moveAttachmentToFinalPlace($attachment, $method, $tmp_name);
 }