Laravel web.php:Storage::disk('local')->download($path):“download”下划线为红色

问题描述 投票:0回答:1
### 
    Laravel web.php: Storage::disk('local')-\>download($path): "download" is underline in red, any help?

web.php

    <?php
    
    use App\Http\Controllers\ClientController;
    
    use Illuminate\Support\Facades\Route;
    
    use App\Http\Controllers\RolesController;
    
    use App\Http\Controllers\UsuariosController;
    
    use App\Http\Controllers\PermisosController;
    
    use App\Http\Controllers\SelectController;
    
    use App\Http\Controllers\UserController;
    
    use Illuminate\Support\Facades\Storage;
    
    Route::get('local/temp/{path}', function (string $path){ return Storage::disk('local')->download($path);})->name('local.temp');

"download" is underline in red(Undefined method 'download'.intelephense(1013))

** 实际上我正在尝试遵循以下说明: ** 第一步:在AppServiceProvider启动方法中添加以下代码。

Storage::disk('local')->buildTemporaryUrlsUsing(function ($path, $expiration, $options) { 返回 URL::temporarySignedRoute('local.temp',$expiration, array_merge($options, ['path' => $path]));});

注意 URL::temporarySignedRoute 接收路由名称 local.temp,我们需要定义它。 第2步:在web.php中添加路由

Route::get('local/temp/{path}', function (string $path){
    return Storage::disk('local')->download($path);
})->name('local.temp');

This will allow downloading of the file using a temporary URL.
Now you can easily generate a temporary URL for the local disk.

disk = Storage::disk('releases-local');return $disk->temporaryUrl($this->path, now()->addMinutes(5));
*************
THIS IS MY EDIT BLADE BUT IM NOT SURE IF I HAVE TO CALL DE TEMPORARYURL IN THIS FILE

<div class="form-group">                  
@if ($image)
Photo Preview:<br>
<img class="img img-circle" style="width:50px;" src="{{ return   Storage::disk('public')->temporaryUrl($image, now()->addMinutes(5)); }}"><br>                                                      
@endif 
</div>
<div class="form-group">
<label for="ImageControl" />Select photo</label>
<input wire:model="image" type="file" class="form-control-file" id="image" placeholder="Image">
@error('image') <span class="error text-danger">{{ $message }}</span> @enderror
</div>
laravel storage
1个回答
0
投票

这看起来不太好,但你可以像这样摆脱 intelephense 警告(通过准确地告诉它这里使用的类):

Route::get('local/temp/{path}', function (string $path){ 
  /** @var \\Symfony\Component\HttpFoundation\StreamedResponse $storage **/
  $storage = Storage::disk('local')
  return $storage->download($path);
})->name('local.temp');
© www.soinside.com 2019 - 2024. All rights reserved.