Stores a file.

@param StorableFileInterface $file mixed content to store
@param string                $path where the file should be stored, including the filename
@return StoredFileInterface
@throws FileStorageException
966386
public function store(StorableFileInterface $file, $path)
    {
        if ( ! $this->filesystem->put($path, $file->content())) {
            throw new FileStorageException("Failed to store '{$file->name()}' to '{$path}'");
        }

        $stored = new DecoratorStoredFile($file);
        $stored->setUrl($this->prefixBaseUrl($path));

        return $stored;
    }
200025
public function createFile(string $path): File {
    $localFile = $this->instantiateFile($path);
    $localFile->create();
    return $localFile;
  }
399123
public static function write($path, $content)
    {
        if (file_exists($path) && is_file($path) && !is_writable($path)) {
            return new PermissionDeniedException("$path is not writable");
        }

        $directory = dirname($path);

        if (!is_writable($directory)) {
            return new PermissionDeniedException("$directory is not writable");
        }

        file_put_contents($path, $content);
    }
221395
public function add_stored_file($file) {
        if (is_numeric($file)) {
            $this->files[$file] = $file;
        } else {
            $this->files[$file->get_id()] = $file;
        }
    }
1340148
protected function createFileEntity($path) {
    $uri = $this->fileUnmanagedCopy($path);
    $file = $this->entityTypeManager->getStorage('file')->create([
      'uri' => $uri,
      'status' => 1,
    ]);
    $file->save();
    $this->storeCreatedContentUuids([$file->uuid() => 'file']);
    return $file->id();
  }
221418
public function saveFile($path, $content)
    {
        $path = $this->cleanFolder($path);

        return $this->disk->put($path, $content, 'public');
    }
379285
public function storePublicly($path, $options = [])
    {
        $options = $this->parseOptions($options);

        $options['visibility'] = 'public';

        return $this->storeAs($path, $this->hashName(), $options);
    }
702434
public function store($path, $value)
    {
        $file = $this->getCacheFile($this->getCacheKey($path));

        if (!is_dir(dirname($file))) {
            mkdir(dirname($file), 0755, true);
        }

        file_put_contents($file, $value);

        return $this;
    }
625904
public function uploadFile(string $file, string $path, string $name)
    {
        // to store the file we have to make sure the directory exists
        foreach ($this->extractDirectories($path) as $dir) {
            // if change to directory fails
            // create the dir and change into it afterwards
            try {
                $this->chDir($dir);
            } catch (\Exception $e) {
                $this->mkDir($dir);
                $this->chDir($dir);
            }
        }
        if (!$this->put($name, $file, FTP_BINARY)) {
            $error   = error_get_last();
            $message = $error['message'];
            throw new RuntimeException(sprintf('error uploading file: %s - %s', $file, $message));
        }
    }
632390
public function store($storagePath = '', $filename = '')
    {
        $path     = $this->getPath();
        $pathinfo = pathinfo($path);
        $data     = file_get_contents($path);

        // Use Original Filename if no specific filename is set
        if (empty($filename)) {
            $filename = $pathinfo['filename'] . '.jpg';
        }

        file_put_contents($storagePath . $filename, $data);

        $this->setLocalStoragePath($storagePath);
        $this->setLocalFilename($filename);

        return $storagePath . $filename;
    }
581555
public static function createFromFile($file) {
    $jsonConfig = json_decode(file_get_contents($file), true);
    return self::createFromConfig($jsonConfig);
  }
370075
public function getFile($path)
    {
        $file = new File($this->getFileSystemId(), $this->getFullPath($path));
        $file->setServiceLocator($this->getServiceLocator());
        return $file;
    }
1215418
public function setFile($file)
    {
        $path = pathinfo((string) $file);

        if (!$path['extension'])
            $file .= '.'.static::$_defaultExt;

        $this->_file = trim($file, DIRECTORY_SEPARATOR);

        return $this;
    }
672521
public function store(UploadedFileSource $file, $folderId, $userId, $originalFileId, $useWizard)
    {
        $tempId = uniqid();
        $tempDir = $this->tempDir.'/'.$tempId.'/';
        $tempName = $tempDir.basename($file->getPath());

        if (!file_exists($tempDir) && !mkdir($tempDir, 0777, true)) {
            throw new StoreUploadedFileException('Error occured while creating temp upload folder.');
        }

        if (!move_uploaded_file($file->getPath(), $tempName)) {
            throw new StoreUploadedFileException('Error occured during uploaded file move.');
        }

        $tempFile = new TempFile(
            $tempId,
            $file->getName(),
            $tempName,
            $file->getMimeType(),
            $file->getSize(),
            $this->hasher->fromPath($tempName),
            $originalFileId,
            $folderId,
            $userId,
            $useWizard
        );

        /*
        $event = new BeforeStoreUploadEvent($this, $tempFile);
        if ($this->dispatcher->dispatch(MediaSiteEvents::BEFORE_STORE_UPLOAD, $event)->isPropagationStopped()) {
            return null;
        }
        */

        $tempFiles = $this->session->get('mediamanager.temp_files');
        $tempFiles[$tempId] = $tempFile;
        $this->session->set('mediamanager.temp_files', $tempFiles);

        /*
        $event = new StoreUploadEvent($this, $tempFile);
        $this->dispatcher->dispatch(MediaSiteEvents::STORE_UPLOAD, $event);
        */

        return $tempFile;
    }
393660
public function putFile($path, $file, $options = [])
    {
        return $this->putFileAs($path, $file, $file->getRename(), $options);
    }
510588
public function save($path = null)
    {
        if (is_null($path)) {
            $path = $this->file;
        }
        imagejpeg($this->image, $path);
        return $this;
    }
265880
public function getFile(string $path): File {
    if($this->isDir($path)) {
      throw new NotAFileException($path);
    }

    return $this->instantiateFile($path);
  }