/** * Create a directory to store some working files. * * @return string */ public function createTempDirectory() { $tempDirectory = storage_path('medialibrary/temp/' . str_random(16)); File::makeDirectory($tempDirectory, 493, true); Gitignore::createIn(storage_path('medialibrary')); return $tempDirectory; }
/** * Return the directory where all files of the given media are stored. * * @param \Spatie\MediaLibrary\Media $media * * @return string */ public function getMediaDirectory(Media $media) { $this->disk->put('.gitignore', Gitignore::getContents()); $directory = $media->id; $this->disk->makeDirectory($directory); $this->disk->makeDirectory($directory . '/conversions'); return $directory; }
/** * Return the directory where all files of the given media are stored. * * @param \Spatie\MediaLibrary\Media $media * * @return string */ public function getMediaDirectory(Media $media) { $this->filesystems->disk($media->disk)->put('.gitignore', Gitignore::getContents()); $directory = $media->id; $this->filesystems->disk($media->disk)->makeDirectory($directory); return $directory; }
/** * Return the directory where all files of the given media are stored. * * @param \Spatie\MediaLibrary\Media $media * * @return string */ public function getMediaDirectory(Media $media, $conversion = false) { $this->filesystems->disk($media->disk)->put('.gitignore', Gitignore::getContents()); $pathGenerator = PathGeneratorFactory::create(); $directory = $conversion ? $pathGenerator->getPathForConversions($media) : $pathGenerator->getPath($media); $this->filesystems->disk($media->disk)->makeDirectory($directory); return $directory; }