# Manual Uploads

use MOIREI\MediaLibrary\Upload;

$upload = new Upload(

$upload->checkType(); // check if type is allowed, returns boolean
$upload->checkSize(); // check if size is below limits, returns boolean
$upload->cleanFilename(); // slugify filename

$location = 'products/chargers';
$namespace = 'Vendor-A'; // optional
$upload->location($location, $namespace);

$file = $upload->save();

# Using the Api

$folder = Folder::find('folder-id');

$upload = Api::upload(

$file = $upload
    	->folder($folder) // set location from folder
    	->name('Space Cat') // name the file model. Separate from filename/storage names
    	->checkSize(true) // throws an error if not valid
    	->checkSize(true) // throws an error if not valid
    	->private() // set file to private. Also accepts bool to make public

# Uploading from URL sources

Sources could be a public url or a local path.

$upload = Upload::fromUrl('https://url');
// or
$upload = Api::upload('https://url');