2

こんにちは、laravel5 を使用してファイルをアップロードしましたそのURLを取得しますか?

dd(Flysystem::get('avatars/kenshin.jpg'));

ここに画像の説明を入力

imgsrc の URL はどこですか?

4

4 に答える 4

1

Assuming you already created a service provider for custom filesystem.

If you don't know how to do that the doc is Here

Route::get('/dropbox',function()
{
  $filename = '/text1.txt';
  $adapter = \Storage::disk('dropbox')->getAdapter();
  $client = $adapter->getClient();
  $link = $client->createTemporaryDirectLink($filename);
  return <<<EOT
    <a href="{$link[0]}">Link</a>
  EOT;
});

PLEASE NOTE THAT you have to prefix a "\" slash on the filename or else it will thrown an exception.

于 2016-04-17T14:34:30.320 に答える
0

コントローラーでメソッドの別のルートを作成し、ドロップボックスからアクセスするファイル名をルートで渡します。コントローラーで getFile() メソッドを使用し、ファイル名を変数に渡します。

public function getFile($file_name)
{
    $client = new Client('dropbox.token','dropbox.appName');
    $this->filesystem = new Filesystem(new Dropbox($client, '/path'));

    try{
        $file = $this->filesystem->read($file_name);
    }catch (\Dropbox\Exception $e){
        return Response::json("{'message' => 'File not found'}", 404);
    }

    $response = Response::make($file, 200);

    return $response;

}
于 2015-12-04T22:29:15.940 に答える