I set up an laravel application at AWS Lambda, using Bref. Everything works fine, including filesystem and s3 filestorage. I use spatie's medialibrary to handle file upload and media conversions, and I can upload a file without any troubles.
The problem appear when I try to make image conversions, using either GD or Imagick.
Whenever I try to make the conversions, I get the following errors:
When using Imagick:
Intervention\Image\Exception\NotReadableException
Unable to read image from path (/tmp/Glide0PSwRU).
When using GD:
Intervention\Image\Exception\NotReadableException
Unsupported image type. GD driver is only able to decode JPG, PNG, GIF or WebP files.
This only happens when running the application at AWS Lambda. If I run at my local environment or at another service like Google App Engine, with the "same" code configs (related to the upload/media conversion).
Create a php/conf.d/php.ini in your project
then add extension=imagick or extension=gd to enable these extensions
You can read the docs here
Related
I'm saving images from local disk to cloud (DO storage) disk by following codes in controller
$claim->addMediaFromDisk($front_image, 'public')->usingFileName("front-image")->toMediaCollection('claim-images', 'do_spaces');
$claim->addMediaFromDisk($right_image, 'public')->usingFileName("right-image")->toMediaCollection('claim-images', 'do_spaces');
$claim->addMediaFromDisk($left_image, 'public')->usingFileName("left-image")->toMediaCollection('claim-images', 'do_spaces');
this trick works but saving those images in 3 different directory in cloud storage. But I want all three images in same directory.
I see there is built in method for adding multiple media from request. But how can I do it form disk. I was expecting something like addMultipleMediaFromDisk(!). Is there any solution ?
Laravel version: 7.30
Spatie media library version: 7.20
//where the original file is saved on the local disk and the conversions on S3.
$media = $claim->addMedia($pathToImage)->storingConversionsOnDisk('s3')
->toMediaCollection('claim-images', 'local');
I am trying to build up a web application with javascript and nodejs. In order to hide the ApplicationID/Key, I use API to handle the data saving.
For example, if I need to save a object on Parse. Instead of using Parse Javascript SDK on the client side, I send the object to the server and then ask server to save the parse.
Everything was working fine until I try to upload images to the server. It turns out I need to somehow upload the images to server before I can save these images to parse class because PFFile need urls to upload the images. But the image at this time is still in local. I was thinking to convert image to base64 string and then server can convert it back to image data and then save it to the parse. However, I didn't succeed with this approach. Can anyone provides some insight? Thanks
When uploading a image, you can just use
uploadImg(photo):void{
var parseFile = new Parse.File("image.png", {base64:photo});
parseFile.save();
}
the parameter photo is base64.
*Are you using AWS s3 to store your images?
I want to get the image list and download those images from a Dropbox's public-shared-link, which I get it from my client.
I'm using Dropbox SDK for ruby and only find the methods to manage files via my Dropbox account, such as put_file, get_file, get_file_and_metadata, get_chunked_uploader, upload and so on.
Is there any way to do that?
Dropbox API v1 has an endpoint that allows you to retrieve metadata about shared links:
https://www.dropbox.com/developers-v1/core/docs#metadata-link
Dropbox API v2 has a similar pair of endpoints that allows you to retrieve metadata and file content, respectively, from shared links:
https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_metadata
https://www.dropbox.com/developers/documentation/http/documentation#sharing-get_shared_link_file
Unfortunately, none of these are currently implemented in the Ruby SDK. You can call them directly though, or modify the Ruby SDK to do so.
Suppose i have one file a.png. In php we will validate it with extension & mime type.
In form i have make above validation so only png files are going to upload. If i make xyz.pdf to a.png it's going to valid.
I would like to validate file with header signature as in .NET.
Also while upload if image is broken then also it gives the message image is corrupted unable to upload.
In PHP we have to use exif_imagetype ? It's only for image what about files like video, audio or any file ?
For png images in php, you can also use createimagefrompng it returns FALSE if it is not a valid png image file.
You can determine the mime type of it. PHP mime_content_type will work on this but it is already deprecated in PHP 5.3. You can use file_info_file into it.
Take a look at this link for a more detailed explaination:
http://www.php.net/manual/en/function.mime-content-type.php
http://us2.php.net/manual/en/function.finfo-file.php
In Drupal 7;
I want to show external images in my nodes by giving its link as "http://www.example.com/aa.jpg"
I don't want them to download to my site
I will make it by the fields
Is there a module for Drupal 7 doing this?
Thank you.
In short...yes!
You can install the Media module along with Remote Stream Wrapper module.
When you add your new image field, choose the 'Media file selector' widget. This:
Provides the ability to use external files with file fields without saving the files to your local files directory. Also provides a 'Remote URL' browser plugin.
A further look at the module page for Remote Stream Wrapper says it does this:
By default the module adds support for any URL using http://, https://, or feed://
Which i think is exactly what you're after.
I'd also recommend installing the Media Browser Plus module which provides a better browser for when your users are picking images.
In Drupal 7 you already have Imagecache as a core module. All you have to do is to install Imagecache External. This is an utility module to allow you to use imagecache(D6)/image derivatives (D7) with external images.
After enabling the module, set the following permissions:
View external images
Fetch external images
Configuration
The module's default configuration is very restrictive.
Excluding admin user or users with the 'Bypass black/white list' permission - the default configuration of the module is to deny all requests to fetch external images.
So to get the module to work, you need to visit admin/settings/imagecache_external and either:
Add some domains to the whitelist -or-
Switch the mode of operation from whitelist to blacklist
I hope this helps.
When I follow this procedure I get this error on Remote URL locally
Warning: Invalid argument supplied for foreach() in element_children() (line 6517 of C:\Drupal Sites\BajaInsider\includes\common.inc).
Warning: Illegal string offset '#children' in drupal_render() (line 5982 of C:\Drupal Sites\BajaInsider\includes\common.inc).
and a dozen other illegal calls for the same variable... Using a NEX theme template as a core. Drupal 7.36, all up to date, no mods to core, testing locally.