Uploading to S3 with Laravel Intervention image returns boolean and not path

Asked
Active3 hr before
Viewed126 times

6 Answers

imageuploadinglaravel
90%

I've tried exif reading data and using imagerotate to no avail, it errors out,1.You may have to encode the image after an Intervention operation on it. To achieve encoding refer this documentation on stream method:Create encoded image stream,https://laracasts.com/discuss/channels/laravel/saving-an-intervention-image-instance-into-amazon-s3, How does the Bladesinging wizard's Extra Attack feature interact with the additional Attack action from the Haste spell?

Encodes the current image in given format and given image quality and creates new PSR-7 stream based on image data.

$image = Image::make(request() - > file('image')) - > orientate() - > encode('jpg');

2.And then storing it with a stream

$path = Storage::disk('s3') - > put('users/'.\Auth::id().
   '/posts', $image - > stream(), 'public');
load more v
88%

Just change this:

   $path = public_path('images/cars/'.$filename);

To this:

   $path = 'images/cars/'.$filename;

Also, make sure that, the target path / location is writable, has write
permission.
72%

I want to do the resizing via queue. So I already uploaded the original image in s3 and it was successful.,The code basically get the file from s3 and it is successful. I dump the results and I believe it is in some form of binary string., Understand Laravel’s timezone,When dumped, the $resizedImage is empty string. I am clueless as to why and haven’t seen any answer.

This is my code:

$originalImage = base64_encode($banner - > getImage('original'));
load more v
65%

I have also tried skipping intervention image and just using Laravel's storage retrieval, for example:,Laravel 5.5 app. I need to retrieve images of driver's licenses from Amazon S3 (already working) and then upload it to Stripe using their api for identity verification (not working).,However, I am not retrieving my files using fopen(). When I retrieve my image from Amazon S3 (using my own custom methods), I end up with an instance of InterventionImage -- essentially, Image::make($imageFromS3) -- and I don't know how to convert this to the equivalent of the call to fopen('/path/to/a/file.jpg', 'r'). I have tried the following:,I would say its not necessary. If you're adding trial days at the time of subscription creation (trial_end parameter when using the API directly), that will take precedence over the trial days defined on a plan anyway!

Stripe's documents give this example:

StripeStripe::setApiKey(PLATFORM_SECRET_KEY);
StripeFileUpload::create(
   array(
      "purpose" => "identity_document",
      "file" => fopen('/path/to/a/file.jpg', 'r')
   ),
   array("stripe_account" => CONNECTED_STRIPE_ACCOUNT_ID)
);

However, I am not retrieving my files using fopen(). When I retrieve my image from Amazon S3 (using my own custom methods), I end up with an instance of InterventionImage -- essentially, Image::make($imageFromS3) -- and I don't know how to convert this to the equivalent of the call to fopen('/path/to/a/file.jpg', 'r'). I have tried the following:

$image - > stream()

$image - > stream() - > __toString()

$image - > stream('data-url')

$image - > stream('data-url') - > __toString()

I have also tried skipping intervention image and just using Laravel's storage retrieval, for example:

$image = Storage::disk('s3') - > get('path/to/file.jpg');
load more v
75%

Now you are able to require the vendor/autoload.php file to PSR-4 autoload the library.,Intervention Imagecache Class is licensed under the MIT License.,Open your Laravel config file config/app.php and add the following lines.,When will php 8 support?

Require the package via Composer:

$ composer require intervention / imagecache

In the $providers array add the service providers for this package.

'providers' => array(

   [...]

   'Intervention\Image\ImageServiceProvider'
),

Add the facade of this package to the $aliases array.

'aliases' => array(

   [...]

   'Image' => 'Intervention\Image\Facades\Image'
),
// run the operations on the image or read a file
// for the particular operations from cache
$img = Image::cache(function($image) {
   return $image - > make('public/foo.jpg') - > resize(300, 200) - > greyscale();
});
// determine a lifetime and return as object instead of string
$img = Image::cache(function($image) {
   return $image - > make('public/foo.jpg') - > resize(300, 200) - > greyscale();
}, 10, true);

If you have Static Resources caching enabled on Nginx please add your cache directory ({route} in config) to static resources handler exclusion:

# where "cache"
is {
   route
}
location~ * ^ \/(?!cache).*\.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|webp|woff|woff2)$ {
expires max;
access_log off;
add_header Cache - Control "public";
}
load more v
40%

Database Driver & Version: MYSQL 5.7y.25,When uploading a file to S3 using the storage facade, using an instance of UploadedFile works fine and the path is returned as expected. However when attempting to use intervention image a simple boolean is returned.,Upload an image with an Intervention Image instance after manipulating,Laravel Version: 5.7.28

$image = $request - > file('photo');
$path = \Storage::disk('s3') - > put('users/'.\Auth::id().
   '/posts', $image, 'public');
dd($path); // /users/1/posts/39grjigrje.jpg
load more v

Other "image-uploading" queries related to "Uploading to S3 with Laravel Intervention image returns boolean and not path"