<?php


namespace Mehrab\Media\Services;


use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Mehrab\Media\Contracts\MediaServiceContract;
use Mehrab\Media\Models\Media;

class CompressFileService extends DefaultFileService implements MediaServiceContract
{

    public static function upload(UploadedFile $file,$fileName,$dir): array
    {
        $extension = strtolower($file->getClientOriginalExtension());
        Storage::putFileAs($dir,$file,$fileName.'.',$extension);
        return ["zip"=> $fileName.'.'.$extension];
    }

    public static function getFileName(){
        return (static::$media->is_private ? 'app\\private\\' : 'app\\public\\') . self::$media->files['zip'];
    }

    public static function thumb(Media $media)
    {
        return url('img/logo/test.png');
    }

}
