aws-s3-media-source's Issues
PHP 8+ error in isBinary() method when trying to open a resource in the bucket that is not accessible
Found a problem on a MODX Cloud site today that was using PHP 8.1 related to binary resources and the resource in question not having the ACLs required to be accessed.
The problem is in core/components/awss3mediasource/model/awss3mediasource/awss3mediasource.class.php
on line 341.
The error suppression on the fread
no longer works in PHP 8+ and will cause a fatal PHP error that stops any of the resources loading in the Media Source view in the Manager when the file being processed returns false from the fopen
- for example, a 403 Forbidden response.
My fix was to add an explicit check right after the fopen
:
if ($fh == false) { return false;}
That way, processing continues and valid resources will still be able to be displayed.
Delete File/Folder, removeObject and removeConatainer Fails
S3 does not have folders or directories so the object name or key needs the trailing delimiter (/). See:
Files need only the Key which appears to be the relative path. So the URL property that MODX adds to the passed parameter needs to be removed.
References
renameContainer() causes files to lose permissions
If I rename a container with an image inside, the image loses it's public
permission.
Going into the AWS console and clicking 'Make Public' on the image allows the image to be seen again.
Broken in MODX 3
As the title states, this is broken in MODX 3
Rename File/Folder and Move Folder
Bug: rename a single file fails.
Features:
- Rename Folder
- Move (drag) Folder to new location within same media source. From an S3 point view move and rename are the same, copy file by file and then delete old.
Thumbnails on s3 bucket not displaying
On MODX 2.8.3 with AWS S3 Media Source Extra installed thumbnails are not displaying for images of any size in the bucket. A small window does pop up displaying a 404 icon. So it makes the file but can't find it to display.
I have contacted MODX support about this. Here's what he last said:
The error is stating that bucket does not yet exist. By the looks of your code, the bucket name is not correct, which is why a file cannot be found.
<Code>NoSuchBucket</Code>
<Message>The specified bucket does not exist</Message>
<BucketName>bmcm-aws</BucketName>
I have confirmed that the bucket name is correctly entered in Media Source.
Also, note that the BucketName in the above code is actually the S3 account name which only appears as part of the URL for the Amazon S3 instance in the Media Source setup.
Any ideas? . . .
Feature add Caching of Container Contents, listDirectory() method
The media source tree does lots of API calls to S3 and this can be resource intensive if you have several S3 media source with nested folders.
Use xPDOCacheManager to cache the what the directory and files are in the media source. When a file or folder is created, updated or deleted also clear the cache for the related tree.
Don't hard-code the S3 URL. If not hard-coded, it's also compatible with Digital Ocean Spaces
I have added 'endpoint' =>'https://sgp1.digitaloceanspaces.com'
into line 54 of model/aws3smediasource.class.php like this:
$this->driver = new Aws\S3\S3Client([
'version' => 'latest',
'endpoint'=> 'https://sgp1.digitaloceanspaces.com',
'region' => $this->xpdo->getOption('region', $this->properties, ''),
'credentials' => [
'key' => $this->xpdo->getOption('key', $this->properties, ''),
'secret' => $this->xpdo->getOption('secret_key', $this->properties, '')
]
]);
and now it works with Digital Ocean Spaces!
(of course you need to change the "sgp1" sub-domain to whatever you're using.)
Unable to view preview Thumbnails for images
I am using a bucket located at an academic institution's S3 instance. Running MODX 2.8.3 with aws-s3-media-source installed. I get the following errors in the manager error log when preview thumbnails are generated by hovering over image file name:
[2022-03-18 08:23:07] (ERROR @ /www/core/components/awss3mediasource/model/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php : 67) PHP warning: count(): Parameter must be an array or an object that implements Countable
[2022-03-18 08:23:08] (ERROR @ /www/core/components/awss3mediasource/model/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php : 67) PHP warning: count(): Parameter must be an array or an object that implements Countable
Additionally the same problem occurs in MODX 3 latest version.
Amazon S3 Media Source not in Package Manager
The README suggests that this package can be found and installed from Package Manager, but I'm not seeing it my package manager when I search for 'aws', 's3', 'media' or other derivations of the name of this package. (I'm on Revo 2.6.1)
Is this a package I should be able to find in Package Manager?
The reason I ask is that I'm not having any success with the built-in s3 bucket media source option in MODX, and I'm hoping this is not the same (updated or whatever).
Create Directory Here fails
Right click on a directory for your S3 media source and then click on Create Directory Here. The Parent Directory (pathRelative) is not set and by default will send to the root on save.
getObjectContents() doesn't return file content for binary files
Example is when using this media source with MoreGallery; that will use getObjectContents() to load the image to create thumbnails/crops, however that wont work because images are binary files.
I'm not quite sure why the check on binary files is there to begin with, and have confirmed it works fine when replacing the ternary with just $contents.
Feature: Limit Media Source to sub directory/folder
Limit a S3 Media Source to sub directory/folder of a given Bucket. Similar to the ability to do so with the local filesystem which uses: basePath and baseUrl.
Why is this needed?
Take for example setting up S3 as a static site with custom domain like: assets.example.com. You want that URL on all assets so you don't want to create lots of different Buckets for each Media Source. It would be ideal to set several Media Sources to one Bucket and to have it be limited to a selected folder.
Feature transfer files from local Media Source to S3
Created a CLI script to transfer file(s) from a local files Media Source to AWS S3 media source.
Features:
- Display list of Media Sources
- Show related properties of selected Media Sources
- Copy or Move directories and files using recursion or a single file. Move will delete/remove local after successful copy to S3 media source.
Requires to install http://climate.thephpleague.com/installation/ via composer
Add a README
Need to have a README.md
Run a `composer update` and release an update
The AWS SDK version that ships in the released 1.0.0 version is really quite old, and not compatible with Guzzle 7 or up. This can cause version conflicts; usually those are resolved by installing the guzzle7 package which forcefully loads the relevant files to avoid that, however that doesn't work with this package currently.
The error thrown is:
( ! ) Fatal error: Uncaught Error: Undefined class constant 'VERSION' in core/components/awss3mediasource/model/vendor/aws/aws-sdk-php/src/functions.php on line 265
I manually ran composer update
in the model folder and that resolved it without further steps.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.