Upload File to S3 using Laravel

Local file

    private function save_s3($path){
        if(is_s3($path) == true){
            return true;
        }

        $file_path = public_path($path);
        $file = File::get($file_path);
        //$file_name = basename($path);
        $result = Storage::disk('s3')->put($path, $file, 'public');

        if($result != true){
            return false;
        }else{
            return true;
        }
    }

Other related helper functions

if(!function_exists('s3_url')){
	function s3_url($path){
		if(is_s3($path) == true){
			return $path;
		}
		
		return 'https://topeak-img.s3.eu-central-1.amazonaws.com' . $path;
	}
}

if(!function_exists('is_s3')){
	function is_s3($url){
		$pattern = '/(s3-|s3\.)?(.*)\.amazonaws\.com/';
		preg_match($pattern, $url, $match);
		if($match == false){
			return false;
		}

		return true;
	}
}