createUploadedFile.

@param string $path
@param string $originalName
@param string $mimeType
@param int $size
@return \Illuminate\Http\UploadedFile
504274
public function createUploadedFile($path, $originalName, $mimeType = null, $size = null)
    {
        $class = class_exists('Illuminate\Http\UploadedFile') === true ?
            'Illuminate\Http\UploadedFile' : 'Symfony\Component\HttpFoundation\File\UploadedFile';

        $mimeType = $mimeType ?: $this->mimeType($path);
        $size = $size ?: $this->size($path);

        return new $class($path, $originalName, $mimeType, $size, UPLOAD_ERR_OK, true);
    }
200025
public function createFile(string $path): File {
    $localFile = $this->instantiateFile($path);
    $localFile->create();
    return $localFile;
  }
448913
public function uploadFiles(string $filename, string $mimetype = '', string $postname = '') {

        $this->params = array_merge($this->params, $this->file($filename, $mimetype, $postname));

        return $this->header(['Content-Type' => 'multipart/form-data']);

    }
221265
public static function uploadFiles($inputName, $path, $encryption = false, $newFilename = false)
    {
        $file       = Request::file($inputName);
        $extension  = $file->getClientOriginalExtension();
        $basename   = basename($file->getClientOriginalName(), '.' . $extension);

        if ($encryption)
        {
            mt_srand();
            $filename = md5(uniqid(mt_rand())) . "." . $extension;
        }
        elseif ($newFilename)
        {
            $filename = $newFilename . "." . $extension;
        }
        else
        {
            $filename = $file->getClientOriginalName();
        }

        $i = 0;
        while (file_exists($path . '/' . $filename))
        {
            $i++;
            $filename = $basename . '-' . $i . '.' . $extension;
        }

        $file->move($path, $filename);

        return $filename;
    }
704349
public static function create(
        UUID $id,
        MIMEType $mimeType,
        StringLiteral $description,
        StringLiteral $copyrightHolder,
        Url $sourceLocation,
        Language $language
    ) {
        $mediaObject = new self();
        $mediaObject->apply(
            new MediaObjectCreated(
                $id,
                $mimeType,
                $description,
                $copyrightHolder,
                $sourceLocation,
                $language
            )
        );

        return $mediaObject;
    }
532173
private function doUpload($src, $originalName)
    {
        $data = $this->buildData($originalName, File::getExtension($originalName, false));
        file_put_contents($data['path'], base64_decode($src));

        $this->application->getEventDispatcher()->dispatch(
            ValidateFileUploadEvent::EVENT_NAME,
            new ValidateFileUploadEvent($data['path'])
        );

        return $data;
    }
309837
public function upload($path, $target)
	{
		$success = false;

		$dir = dirname($target);

		if (!is_dir($dir))
		{
			if (!$this->makeDirectory($dir))
			{
				return $success;
			}
		}

		if (is_writeable($dir) && move_uploaded_file($path, $target))
		{
			if ($this->setPermissions($target))
			{
				$success = true;
			}
		}

		return $success;
	}
1114614
protected function getMimeType($originalName)
    {
        $mimeType = (string) $this->request->header('content-type');
        if (empty($mimeType) === true) {
            $mimeType = $this->files->mimeType($originalName);
        }

        return $mimeType;
    }
849657
public function uploadFile($fileName, $fileLocation, \Google_Service_Drive_DriveFile $folder = null, $uploadType = 'media')
    {
        //Insert a file
        $file = new \Google_Service_Drive_DriveFile();
        $file->setTitle($fileName);
        $fileInfo = new \finfo(FILEINFO_MIME_TYPE);
        $mimeType = $fileInfo->file($fileLocation);
        $file->setDescription($fileName);
        $file->setMimeType($mimeType);
        if ($folder !== null) {
            $parent = new \Google_Service_Drive_ParentReference();
            $parent->setId($folder->getId());
            $file->setParents(array($parent));
        }
        $data = file_get_contents($fileLocation);
        try {
            return $this->service->files->insert($file, array(
               'data'       => $data,
               'mimeType'   => $file->getMimeType(),
               'uploadType' => $uploadType,
            ));
        } catch (\Google_Service_Exception $obj_ex) {
            $this->service->getClient()->getLogger()->error($obj_ex->getMessage());
            return false;
        }
    }
775558
public function makeFromFileInfo(SplFileInfo $data, $name = null, $mimeType = null)
    {
        $file = new SplFileInfoStorableFile;
        $file->setData($data);

        if (null !== $mimeType) {
            $file->setMimeType($mimeType);
        } else {
            $file->setMimeType(
                $this->mimeTypeHelper->guessMimeTypeForPath($data->getRealPath())
            );
        }

        if (empty($name)) {
            $name = pathinfo($data->getRealPath(), PATHINFO_BASENAME);
        }

        if (null !== $name) {
            $file->setName($name);
        }

        return $this->getReturnPreparedFile($file);
    }
1144391
public function makeFromUrl($url, $name = null, $mimeType = null)
    {
        try {
            $localPath = $this->downloader->download($url);

        } catch (Exception $e) {

            throw new CouldNotRetrieveRemoteFileException(
                "Could not retrieve file from '{$url}'",
                $e->getcode(),
                $e
            );
        }

        if (null === $name) {
            $name = $this->getBaseNameFromUrl($url);
        }

        // Always flag as uploaded, since we downloaded to a local path
        return $this->uploaded()->makeFromLocalPath($localPath, $name, $mimeType);
    }
14914
static public function createFileName($originalName)
    {
        $returnValue = uniqid(hash('crc32', $originalName));

        $ext = @pathinfo($originalName, PATHINFO_EXTENSION);
        if (!empty($ext)){
            $returnValue .= '.' . $ext;
        }

        return $returnValue;
    }
1362370
public function readPath($path, $mimeType = null)
    {
        return $this->schemaFactory()->create(
            $this->reader()->readPath($path, $mimeType)
        );
    }
1126078
public function uploadUrl($key, $acl, $mimeType = null, $cacheControl = null, $expires = null) {
		try {
			$optionsData = [
				'ACL' => $acl,
				'Bucket' => $this->bucket,
				'ContentType' => $mimeType,
				'Key' => $key
			];

			if(!empty($cacheControl)) {
				$optionsData[] = ['CacheControl' => $cacheControl];
			}

			if(!empty($expires)) {
				$optionsData[] = ['Expires' => $expires];
			}

			$putCommand = $this->client->getCommand('PutObject',$optionsData);
			$request = $this->client->createPresignedRequest($putCommand, '+20 minutes');
			$signedUrl = (string)$request->getUri();

			return new OtherS3UploadInfo($key,$signedUrl,$acl);
		}
		catch(AwsException $ex) {
			Logger::error('S3 Generate File Upload URL Error', ['exception' => $ex->getMessage()]);
			throw new StorageException($ex->getMessage(), $ex->getCode(), $ex);
		}
	}
697281
public function file($key = null, $default = null)
    {
        if ($this->needParser()) {
            $this->treatPutRequest();
            $fileObjects = [];
            if ($this->hasFile($key)) {
                $files = $this->fileParser->getFiles($key);
                foreach ($files as $key => $file) {
                    $originalName  = Arr::get($file, 'name');
                    $mimeType      = Arr::get($file, 'type');
                    $path          = Arr::get($file, 'tmp_name');
                    $size          = Arr::get($file, 'size');
                    $fileObjects[] = new \Illuminate\Http\UploadedFile($path, $originalName, $mimeType, $size);
                }
            }
            if (count($fileObjects) == 0) {
                return $default;
            } elseif (count($fileObjects) == 1) {
                return $fileObjects[0];
            }

            return $fileObjects;
        }

        return parent::file($key, $default);
    }
424647
public function copy(string $fromPath, string $toPath, array $mimeType) : bool
	{
		$fromPath = $this->normalizePath($fromPath);
		
		$toPath = $this->normalizePath($toPath);
		
		// If plain/text, its a folder
		if (substr($mimeType['mimetype'], 0, 4) === 'text') {
			$requestUrl = $this->siteUrl.'/sites/'.$this->siteName.'/_api/Web/GetFolderByServerRelativeUrl(\''.$this->folderPath.$fromPath.'\')/copyTo(strNewUrl=\''.$this->folderPath.$toPath.'\', bOverWrite=true)';
		} else {
			$requestUrl = $this->siteUrl.'/sites/'.$this->siteName.'/_api/Web/GetFileByServerRelativeUrl(\''.$this->folderPath.$fromPath.'\')/copyTo(strNewUrl=\''.$this->folderPath.$toPath.'\', bOverWrite=true)';
		}
		
		$options = [
			'headers' => $this->requestHeaders,
		];
			
		$response = $this->send('POST', $requestUrl, $options);
		
		return $response->getStatusCode() === 200 ? true : false;
	}
12241
public function createBackup($originalPath)
    {
        // Bail if file does not exist
        if (!file_exists($originalPath)) {
            return false;
        }

        $pathinfo = pathinfo($originalPath);

        $backupPrefered = $pathinfo['dirname'] . '/' . $pathinfo['filename'] . '.' . $pathinfo['extension'] . '.bkp';
        $backupFile = $backupPrefered;

        $i = 0;
        while (file_exists($backupFile)) {
            $i++;
            $backupFile = $backupPrefered . $i;
        }

        if (copy($originalPath, $backupFile)) {
            return $backupFile;
        }

        return false;
    }