@param UploadedFile $file

@return \Librinfo\MediaBundle\Entity\File
483403
public function setFile($file = null)
    {
        if ($file instanceof UploadedFile) {
            $this->file = base64_encode(file_get_contents($file));
        } else {
            $this->file = $file;
        }

        return $this;
    }
1335134
public function uploadImg($file)
    {
        return $this->auth(function () use ($file) {
            $http = $this->http([
                'method' => 'post',
                'dataType' => 'json',
                'timeout' => 30000,
                'url' => $this->baseUrl . 'cgi-bin/media/uploadimg?access_token=' . $this->accessToken,
                'files' => [
                    'media' => $file,
                ],
            ]);

            return $http;
        });
    }
1052518
public function replaceFile(File $fileEntity, UploadedFile $file)
	{
		$entityManager = $this->getDoctrineEntityManager();
		$oldFileIsImage = $fileEntity instanceof Image;
		$newFileIsImage = $this->isMimeTypeImage($file->getMimeType());

		if ($oldFileIsImage !== $newFileIsImage) {
			throw new Exception\UploadFilterException(self::VALIDATION_IMAGE_TO_FILE_REPLACE_MESSAGE_KEY, 'New file should be image too');
		}

		$originalFile = clone($fileEntity);
		$entityManager->detach($originalFile);

		// setting new data
		// The name is not changed by Bug #6756
//		$fileEntity->setFileName($file['name']);
		$fileEntity->setSize($file->getSize());
		$fileEntity->setMimeType($file->getMimeType());

		// This must be call before removing the old file
		$this->validateFileUpload($fileEntity, $file->getPathname());

		$this->removeFileInFileSystem($originalFile);

		$this->storeFileData($fileEntity, $file->getPathname());

		// additional jobs for images
		if ($fileEntity instanceof Image) {
			
			$imageProcessor  = $this->getImageResizer();
			// store original size
			$imageInfo = $imageProcessor->getImageInfo($fileEntity);
			$fileEntity->setWidth($imageInfo->getWidth());
			$fileEntity->setHeight($imageInfo->getHeight());
			// reprocess sizes
			$this->recreateImageSizes($fileEntity);
		}

		$fileEntity->setModificationTime();

		$entityManager->flush();
	}
457680
public function resize(UploadedFile $file, $style)
    {
        $quality = $this->option('quality', 90);

        $this->imagine = new $this->image_processor;

        $file_path = @tempnam(sys_get_temp_dir(), 'STP') . '.' . $file->getClientOriginalName();
        list($width, $height, $option, $enlarge) = $this->parseStyleDimensions($style);
        $method = 'resize' . ucfirst($option);

        if ($method == 'resizeCustom') {
            $this->resizeCustom($file, $style, $enlarge)
                ->save($file_path, [
                    'quality' => $quality,
                ]);

            return $file_path;
        }

        $image = $this->imagine->open($file->getRealPath());

        // Orient the file programmatically
        if ($this->option('auto_orient', false)) {
            $image = $this->autoOrient($file->getRealPath(), $image);
        }

        // Force a color palette
        if ($palette = $this->option('color_palette')) {
            $image->usePalette(new $palette);
        }

        $this->$method($image, $width, $height, $enlarge)
            ->save($file_path, [
                'quality' => $quality,
                'flatten' => false,
            ]);

        return $file_path;
    }
490661
public static function create(array $file)
    {
        if (!isset($file[ 'tmp_name' ])) {
            throw new \InvalidArgumentException('The tmp_name key is required.');
        }

        return new UploadedFile(
            $file[ 'tmp_name' ],
            isset($file[ 'name' ])
            ? $file[ 'name' ]
            : null,
            isset($file[ 'size' ])
            ? $file[ 'size' ]
            : null,
            isset($file[ 'type' ])
            ? $file[ 'type' ]
            : null,
            isset($file[ 'error' ])
            ? $file[ 'error' ]
            : UPLOAD_ERR_OK
        );
    }
1103628
protected function unzipModule(UploadedFile $file)
    {
        $extractPath = false;
        $zip = new ZipArchiver(true);
        if (!$zip->open($file->getRealPath())) {
            throw new \Exception("unable to open zipfile");
        }

        $extractPath = $this->tempdir();

        if ($extractPath !== false) {
            if ($zip->extract($extractPath) === false) {
                $extractPath = false;
            }
        }

        $zip->close();

        return $extractPath;
    }
887779
public function upload(UploadedFile $uploadedFile)
    {
        if ($this->blob === null) {
            throw new \Exception('Blob path is not set yet.');
        }

        $this->makeDirectory();

        $path = $this->blob->path;
        $ext = $uploadedFile->getClientOriginalExtension();
        $name = Slug::make(pathinfo($uploadedFile->getClientOriginalName(), PATHINFO_FILENAME));
        $uniqueName = $this->getUniqueFileName($path, $name, $ext);

        $fullName = $uniqueName . '.' . $ext;

        $this->storage->putFileAs($path, $uploadedFile, $fullName);

        $path .= '/' . $fullName;

        $this->blob->path = $path;

        if ($this->getMetaData()->isImage()) {
            (new ThumbService($this->package))
                ->resize($this->getMetaData()->getPath());
        }

        return $this->fullDetails();
    }
4215
public function upload(UploadedFile $file)
    {
        self::$generic_file->moveUploadedFile(new File($file,
            $file->getClientOriginalName()), null, $this);

        return $this;
    }
50054
public function upload(UploadedFile $uploadedFile, $id = null)
    {
        if ($this->validatesUploadedFile())
        {
            $this->validateUploadedFile($uploadedFile);
        }

        return $this->processUpload($uploadedFile, $id);
    }
1306625
public function moveUpload(UploadedFile $file) {

        // Nest the uploaded file into unique sub directory and a unqiue name
        $path = $this->makeNestedAndUniquePath($file->getClientOriginalName());

        // Move the uploaded file to the destination using Flysystem and return
        // the new path
        $this->manager->move('tmp://'.$file->getFilename(), 'disk://'.$path);

        // Return the URL of the upload.
        return $this->helpers->url($path);
    }
1208157
public function setFile(File $file = null)
    {
        $this->file = $file;
        // Until php7/uploaderbundle 1.7
        if ($file instanceof UploadedFile) {
            $this->setMimeType($file->getMimeType());
            $this->setName($file->getClientOriginalName());
            $this->setSize($file->getSize());
        }
        
        return $this;
    }
982880
public function setFile(\BiberLtd\Bundle\FileManagementBundle\Entity\File $file) {
        if($this->setModified('file', $file)->isModified()) {
            $this->file = $file;
        }

        return $this;
    }
803857
protected function prepareForeach(UploadedFile $file = null)
    {
        $this->name = $this->getStoreName($file);

        return tap($this->upload($file), function () {
            $this->name = null;
        });
    }
332126
public function up(UploadedFile $file)
    {
        //设置文件名称
        $this->oriName = $file->name;
        //设置文件大小
        $this->fileSize = $file->size;
        $this->fileType = $this->getExtension();
        $this->fullName = $this->getFullName();
        $this->filePath = $this->getFilePath();
        $this->fileName = $this->getFileName();
        $dirName = dirname($this->filePath);
        if (!is_dir($dirName)) {//递归创建保存目录
            FileHelper::createDirectory($dirName, $this->dirMode, true);
        }
        if (!($file->saveAs($this->filePath) && file_exists($this->filePath))) {
            $this->stateInfo = Yii::t('attachment', 'An error occurred while saving the file.');
            return false;
        } else { //移动成功
            $this->saveModel();
            $this->stateInfo = 'SUCCESS';
            return true;
        }
    }
1347867
private function createModel(UploadedFile $file, Request $request)
    {
        $model = app()->make(File::class, [
            'file'  => $file,
            'disk'  => $request->get('storage', 'public'),
            'group' => $request->get('group'),
        ])->load();

        $model->url = $model->url();

        return $model;
    }
1172929
public function getUploadFileName(UploadedFile $file)
    {
        if (is_callable($this->uploadFileNameRule)) {
            return call_user_func($this->uploadFileNameRule, $file);
        }

        return $this->getDefaultFileName($file);
    }
1321140
public function addFile(\Haven\CoreBundle\Entity\File\File $file)
    {
        $this->files[] = $file;

        return $this;
    }