-1

I'm using Dingo/API and this is a transformer that returns me data

return [
            'id' => $site->id,
            'path' => asset($site->path),
            'siteLink' => $site->site_link,
            'features' => $features,
        ];

Generated link looks good, however when I try to access it from my Angular app it's said that

Failed to load resource: the server responded with a status of 404 (Not Found) http://api.example.com/public/thumbnails/ySOSYhaCCRcH3t9agsco3ToUwoHxMZJ3r1PhEHlM.jpeg

Sergey
  • 7,184
  • 13
  • 42
  • 85

2 Answers2

1

Are you sure that your image stored in public/public folder? asset() helper generate a asset path from public folder. So, in your property $site->path you getting a path to your image like 'public/yourimage.jpeg'. Try to remove 'public' from your $site->path.

0

The solution.

In filesystems.php local disk was specified as a default disk. According to docs local disk is supposed to be invisible for public and stored inside storage/app. Thus I was trying to save my file using local disk and accessing it with path public/....

Option #1

Change in filesystems.php default disk to public and use Storage::url() to get url to image.

Option #2

Use $file->store('path', 'public') and Storage::disk('public')->url('path')

So that used disk is specified explicitly.

The given path will contain link close to http://example.com/storage/path.

Sergey
  • 7,184
  • 13
  • 42
  • 85