LaraMediaMover is a versatile Laravel package that simplifies the movement and management of multimedia files of all types, including images, videos, and documents. It provides a comprehensive solution for uploading, storage, renaming, and handling files, ensuring a seamless development experience for Laravel projects.
zakariayacine/laramediamover is a Laravel package for laramediamover is a versatile laravel package that simplifies the movement and management of multimedia files of all types, including images, videos, and documents. it provides a comprehensive solution for uploading, storage, renaming, and handling files, ensuring a seamless development experience for laravel projects..
It currently has 3 GitHub stars and 17 downloads on Packagist (latest version 1.0.4).
Install it with composer require zakariayacine/laramediamover.
Discover more Laravel packages by zakariayacine
or browse all Laravel packages to compare alternatives.
Last updated
LaraMediaMover is a versatile Laravel package that simplifies the movement and management of multimedia files of all types, including images, videos, and documents. It provides a comprehensive solution for uploading, storage, renaming, and handling files, ensuring a seamless development experience for Laravel projects.
You can install this package via Composer by running the following command:
composer require zakariayacine/laramediamover
The package will automatically register itself.
Next, you should publish the package configuration file using the following command:
php artisan vendor:publish --tag=laramediamover-config
This will create a laramediamover.php configuration file in your config directory. You can customize the configuration according to your needs.
To use LaraMediaMover, you need to create an instance of the LaraMediaMover class and call the moveFile method. Here's an example of how to use it:
use Zakariayacine\LaraMediaMover\LaraMediaMover;
// Instantiate LaraMediaMover with the file content, extension, and optional parameters
$mediaMover = new LaraMediaMover($fileContent, 'jpg', 'my_image.jpg', 'public');
// Move the file and get its URL
$mediaUrl = $mediaMover->moveFile();
if ($mediaUrl) {
// The file has been successfully moved, and $mediaUrl contains its URL
// You can use $mediaUrl as needed in your application
} else {
// An error occurred during the file move process
// Handle the error appropriately
}
In the above example:
$fileContent is the content of the media file you want to move.'jpg' is the file extension.'my_image.jpg' is the desired file name.'public' is the storage disk you want to use.You can customize these parameters according to your requirements.
You can customize the package's behavior by modifying the laramediamover.php configuration file located in your config directory. This file allows you to define default settings for the package.
The package may throw a MediaMoveException in case of an error during the media move process. You can catch this exception to handle errors gracefully.
use Zakariayacine\LaraMediaMover\Exceptions\MediaMoveException;
try {
// Attempt to move the media file here
} catch (MediaMoveException $e) {
// Handle the error, log it, or return an error response
}
To illustrate how the LaraMediaMover package generates URLs with hashed file names, here are some examples using hashed names:
document.pdf4e76275d9d4b3b51c1ab9a44d5c0c15399d02889163361749e1645aa27b5eaffed001.pdfPDF/4e76275d9d4b3b51c1ab9a44d5c0c15399d02889163361749e1645aa27b5eaffed001.pdfhttps://example.com/storage/PDF/4e76275d9d4b3b51c1ab9a44d5c0c15399d02889163361749e1645aa27b5eaffed001.pdfpicture.jpg7b5eaffed0014e76275d9d4b3b51c1ab9a44d5c0c15399d02889163361749e1645aa27b5ea.jpgIMAGES/7b5eaffed0014e76275d9d4b3b51c1ab9a44d5c0c15399d02889163361749e1645aa27b5ea.jpghttps://example.com/storage/IMAGES/7b5eaffed0014e76275d9d4b3b51c1ab9a44d5c0c15399d02889163361749e1645aa27b5ea.jpgvideo.mp45d9d4b3b51c1ab9a44d5c0c15399d02889163361749e1645aa27b5ea5d9d4b3b51.mp4VIDEOS/5d9d4b3b51c1ab9a44d5c0c15399d02889163361749e1645aa27b5ea5d9d4b3b51.mp4https://example.com/storage/VIDEOS/5d9d4b3b51c1ab9a44d5c0c15399d02889163361749e1645aa27b5ea5d9d4b3b51.mp4audio.mp3ea5d9d4b3b51c1ab9a44d5c0c15399d02889163361749e1645aa27b5eaaudio.mp3AUDIO/ea5d9d4b3b51c1ab9a44d5c0c15399d02889163361749e1645aa27b5eaaudio.mp3https://example.com/storage/AUDIO/ea5d9d4b3b51c1ab9a44d5c0c15399d02889163361749e1645aa27b5eaaudio.mp3other.docx1c1ab9a44d5c0c15399d02889163361749e1645aa27b5eaaother.docxOTHER/1c1ab9a44d5c0c15399d02889163361749e1645aa27b5eaaother.docxhttps://example.com/storage/OTHER/1c1ab9a44d5c0c15399d02889163361749e1645aa27b5eaaother.docxThese examples showcase how the LaraMediaMover package generates URLs with hashed file names for different types of media files based on their extensions and storage paths. The hashed file names provide security and uniqueness to each file.
This package is open-sourced software licensed under the MIT license.
Please customize this README to include specific instructions, details, or additional information related to your package. Replace the placeholder content with actual package details, usage instructions, and license information.
For more information and updates, visit the LaraMediaMover GitHub repository.