barryvdh / elfinder-flysystem-driver

elFinder driver for Flysystem
183 stars 41 forks source link

AWS S3 delete returns ERROR_RM on success #12

Closed phazei closed 9 years ago

phazei commented 9 years ago

It returns the message "Unable to remove 'Close'". It say 'Close' regardless of the filename.

It seems the issue is in Driver.php. The _unlink method expects to return a bool although it returns $this->fs->delete($path)

The filesystems S3 adapter delete method returns the "DeleteMarker" of the result which comes from the AWS\Result data. That data response looks like this:

Aws\Result Object
(
    [data:Aws\Result:private] => Array
        (
            [DeleteMarker] => ""
            [VersionId] => ""
            [RequestCharged] => ""
            [@metadata] => Array
                (
                    [statusCode] => 204
                    [effectiveUri] => https://s3.amazonaws.com/bucketName/filename.JPG
                    [headers] => Array
                        (
                            [x-amz-id-2] => LONGHASHTHINGHERE=
                            [x-amz-request-id] => ANOTHERHASH
                            [date] => Thu, 02 Jul 2015 03:25:18 GMT
                            [server] => AmazonS3
                        )
                )
        )
)

The deleteMarker is going to be blank in most cases, unless the bucket has file versioning turned on, in which case it's going to be a string or something.

Either way, it returns an empty string in the case in which it's successful. So the file is deleted, but an error message is sent back instead. If the view is refreshed, the file is gone.

It doesn't even check the statusCode to make sure it's a 200, so I'm not sure what would happen if there were a permission error, although that's definitely on the s3 adapter side of things.

I'm not sure if the flysystem-aws-s3-v3 package is suppose to be returning a boolean, or if the elfinder-flysystem-driver should be dealing with the particular response from it.

phazei commented 9 years ago

Looking more at the S3 code I submitted a ticket for it there as well.

phazei commented 9 years ago

This was fixed in the flysystem-aws-s3-v3 driver.