fopen and fputs for Amazon S3 by Laravel

0

In php, is it possible to send an image file, obtained through the return of a request by cURL, directly to an S3 bucket using Laravel's methods? If yes, how?

    
asked by anonymous 13.07.2018 / 16:52

1 answer

0

I was able to solve the problem without using fopen / fputs, just taking the curl_exec return and using it in the laravel file storage for storage:

  private function FileUpload($path, $url){
   $curl = curl_init();
   curl_setopt($curl, CURLOPT_URL, $url);
   curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
   curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/6.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.7) Gecko/20050414 Firefox/1.0.3");
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
   $content = curl_exec($curl);
   if (curl_error($curl)) {
     return false;
   }
   curl_close($curl);
   Storage::disk('s3')->put($path, $content);
    
13.07.2018 / 19:34