2016-09-15 9 views
0

アンドロイドとiOSデバイスで使用されるAPIスタックを開発中です。 1つのAPIメソッドがサーバーからイメージをダウンロードするために使用されるはずです。ダウンロードを開始するためにfollowngコードを使用しましたが、Hurlを使用してテストした場合、メソッドは永久に0バイトを返します。私はLaravel 5.1、REST APIを使用した画像のダウンロード

Route::get('files/downloadimage/{cardid}', ['middleware'=>'jwt.auth', 'uses' => '[email protected]'])->name('files.download'); 

を持っているのroutes.phpで

if(file_exists($file)) //$file contains absolute path 
      { 
       EventLogger::info('##### Downloading the file#### '); 
        $filename = basename($file); 
        $headers = array('Content-Type: image/png'); 
       response()->download($file,$filename,$headers); 
      } 

私が間違って何をやっている場合は私に知らせてください。

答えて

4

あなたの方法で戻る必要があります。

return response()->download($file,$filename,$headers); 
+0

ありがとうございます。愚かな私。 – logeeks

関連する問題