Generates a name for the file and uploads it to s3

@param UploadedFile $file
@return FileUploadedModel
766343
public function uploadFile(UploadedFile $file)
    {
        $path =   $this->env . '/'  . md5(time() . random_int(1,100000)) . '.'. $file->guessClientExtension();
        /** @var Result $result */
        $result = $this->client->putObject([
            'ACL' => 'public-read',
            'Bucket' => $this->bucketName,
            'SourceFile' => $file->getRealPath(),
            'Key' => $path
        ]);

        return new FileUploadedModel($path, $result->get('ObjectURL'), FileUploadedModel::VENDOR_S3);
    }
95682
public function upload(\Symfony\Component\HttpFoundation\File\UploadedFile $file) {
    
    // We simply move the uploaded file to the target directory
    $result = $file->move(\Config::get('plupload::plupload.upload_dir'), $file->getClientOriginalName());

    // Return the result of the upload
    return $this->respond(array('OK' => ($result) ? 1 : 0));
  }
741922
protected function createFromArray($file)
	{
		$file = new SymfonyUploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['size'], $file['error']);

		return $this->createFromObject($file);
	}
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;
    }
1338231
protected function convertFileInformation($file)
    {
        if ($file instanceof UploadedFile) {
            return $file;
        }

        $file = $this->fixPhpFilesArray($file);
        if (\is_array($file)) {
            $keys = array_keys($file);
            sort($keys);

            if ($keys == self::$fileKeys) {
                if (UPLOAD_ERR_NO_FILE == $file['error']) {
                    $file = null;
                } else {
                    $file = new UploadedFile($file['tmp_name'], $file['name'], $file['type'], $file['error']);
                }
            } else {
                $file = array_map([$this, 'convertFileInformation'], $file);
                if (array_keys($keys) === $keys) {
                    $file = array_filter($file);
                }
            }
        }

        return $file;
    }
764168
protected function customiseFile(File $file)
    {
        $customizedfile = $file->customise(array(
            'UploadFieldThumbnailURL' => $this->getThumbnailURLForFile($file),
            'UploadFieldDeleteLink' => $this->getItemHandler($file->ID)->DeleteLink(),
            'UploadFieldEditLink' => $this->getItemHandler($file->ID)->EditLink(),
            'UploadField' => $this
        ));

        // render file buttons
        return $customizedfile->customise(array(
                'UploadFieldFileButtons' => (string) $file->renderWith($this->getTemplateFileButtons(), array(
                    'IconRemove' => $this->IconRemove(),
                    'IconEdit' => $this->IconEdit(),
                    'EditEnabled' => $this->EditEnabled(),
                ))
        ));
    }
76616
protected function resolveTempFileName(UploadedFile $file)
    {
        $name      = $file->getClientOriginalName();
        $extension = File::extension($name);
        $subdir    = sha1(time());
        $directory = storage_path() . '/app/uploads/' . $subdir;
        $filename  = sha1(time() . time()) . ".{$extension}";
        return ['directory' => $directory, 'subdir' => $subdir, 'filename' => $filename];
    }
430238
public function upload(UploadedFile $file = null)
    {
        if ($file === null) {
            return '';
        }

        $fileName = $this->getFileName($file);
        $file->move($this->getTargetDir(), $fileName);

        return $fileName;
    }
1348543
public function saveFile(UploadedFile $file)
    {
        Validator::validate(
            [$this->getName() => $file],
            $this->getUploadValidationRules(),
            $this->getUploadValidationMessages(),
            $this->getUploadValidationTitles()
        );

        $path = $file->storeAs(
            $this->getUploadPath($file),
            $this->getUploadFileName($file),
            $this->getDisk()
        );

        return $this->getFileInfo($path);
    }
33631
public function prepare($file)
    {
        if (request()->has(static::FILE_DELETE_FLAG)) {
            return $this->destroy();
        }

        $this->name = $this->getStoreName($file);

        return $this->uploadAndDeleteOriginal($file);
    }
499953
public function file(UploadedFile $file)
	{
		$this->file = $file;
		$this->filename = $file->getClientOriginalName();
		$this->sanitizeFilename();

		return $this;
	}
807353
public function getUploadFileName(UploadedFile $file)
    {
        if (! is_callable($this->uploadFileName)) {
            return $this->defaultUploadFilename($file);
        }

        return call_user_func($this->uploadFileName, $file);
    }
1064552
public function uploadImage(UploadedFile $file)
    {
        $image = $this
            ->imageManager
            ->createImage($file);

        $this
            ->mediaEventDispatcher
            ->dispatchImagePreUploadEvent($image);

        $this->imageObjectManager->persist($image);
        $this->imageObjectManager->flush($image);

        $this->fileManager->uploadFile(
            $image,
            file_get_contents($file->getRealPath()),
            true
        );

        $this
            ->mediaEventDispatcher
            ->dispatchImageOnUploadEvent($image);

        return $image;
    }
98431
protected function generateFilename(UploadedFile $uploadedFile)
    {
        // Retrieve original file name
        $filePath = $uploadedFile->getClientOriginalName();

        // Parse URL
        $filePath = pathinfo($filePath);

        // Sanitize filename
        $filename = preg_replace('/[^a-z0-9_-]/ui', '', $filePath['filename']);

        // Append random sting and extension to filename
        $filename .= '_'.Str::random(10);

        return $filename;
    }
1117871
public function getName()
    {
        if ($this->file instanceof UploadedFile) {
            return $this->file->getClientOriginalName();
        }

        return $this->file->getFilename();
    }
97897
protected function addUploadedFile($file)
    {
        $this->clear();

        $this->uploaded_file = $this->getFileManager()->make($file);

        // Get the original values
        $filename = $this->uploaded_file->getClientOriginalName();
        $content_type = $this->uploaded_file->getMimeType();

        // Set model values
        $this->instanceWrite('file_name', $filename);
        $this->instanceWrite('file_size', $this->uploaded_file->getSize());
        $this->instanceWrite('content_type', $content_type);
        $this->instanceWrite('updated_at', date('Y-m-d H:i:s'));
        $this->instanceWrite('queued_file', null);

        // Queue all styles for writing
        $this->setQueue('write', $this->styles);
    }
246931
public function make(UploadedFile $file, array $attributes = [])
    {
        return $this->save($file->getClientOriginalName(), file_get_contents($file), $attributes);
    }