Displaying image retrieved from google drive

  html, laravel, php

i successfully set up my connection to google drive and saved an image on it. now i want to retrieve it in my blade view. unfortunately, i cannot put the response in src of the <img> tag, because it returns image itself and not a path to it.

i tried using Intervention Image package, but when i used the make() method, i inspected it and it still had no path attribute, so i assume there is not any, to be made this easily. can i display the image without it having a path? or how do i create a temporary path for the returned image, if it is possible, in one line?

i have the image data in this collection

$storage = collect(Storage::cloud()->listContents($this->getGoogleFolderId(), false));

my attempts to gather as much information as possible:

dd($storage->where('name', $breakdowns->first()->image->path025)->first());

returns:

array:10 [▼
  "name" => "2020-10-18-16-46-25-lq.jpg"
  "type" => "file"
  "path" => "1aCS7hRWQWjVwLdF_nn5NKTKJZUbRyq2M/1qTUzjvN6qQBHpGKvN1Xic4SYsVsEgskR"
  "filename" => "2020-10-18-16-46-25-lq"
  "extension" => "jpg"
  "timestamp" => 1603032376
  "mimetype" => "image/jpeg"
  "size" => 59213
  "dirname" => "1aCS7hRWQWjVwLdF_nn5NKTKJZUbRyq2M"
  "basename" => "1qTUzjvN6qQBHpGKvN1Xic4SYsVsEgskR"
]

and this:

dd(IImage::make(Storage::disk('google')->get($storage->where('name', $breakdowns->first()->image->path025)->first()['path'])));

returns:

InterventionImageImage {#1562 ▼
  #driver: InterventionImageGdDriver {#1555 ▼
    +decoder: InterventionImageGdDecoder {#1567 ▼
      -data: null
    }
    +encoder: InterventionImageGdEncoder {#1561 ▼
      +result: null
      +image: null
      +format: null
      +quality: null
    }
  }
  #core: gd resource @747 ▼
    size: "1079x1758"
    trueColor: true
  }
  #backups: []
  +encoded: ""
  +mime: "image/jpeg"
  +dirname: null
  +basename: null
  +extension: null
  +filename: null
}

Source: Ask PHP

LEAVE A COMMENT