S3 URI validated as regular directory on copy or move

Created on 4 June 2024, 10 months ago
Updated 8 July 2024, 9 months ago

Trying:

\Drupal::service('file_system')->copy('private://my-folder/my-file.txt', 's3://my-bucket/my-file.txt');

ends on exception with the follwing message:

The specified file 'private://my-folder/my-file.txt' could not be copied because the destination directory 's3://my-bucket' is not properly configured. This may be caused by a problem with file or directory permissions.

It seems that the copy method calls to prepareDestination, then to prepareDirectory which relies on the same method from the decorated class that simply checks if the destination is a directory in the local filesystem.

Should do it check for the existence of the bucket/directory on the remote S3 service instead?

โœจ Feature request
Status

Closed: cannot reproduce

Version

3.0

Component

Code

Created by

๐Ÿ‡ช๐Ÿ‡ธSpain manuel.adan ๐ŸŒŒ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @manuel.adan
  • Status changed to Postponed: needs info 10 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States cmlara
    \Drupal::service('file_system')->copy('private://my-folder/my-file.txt', 's3://my-bucket/my-file.txt');
    

    Did you include the actual bucket name here ? If so that would be incorrect use of the Drupal S3FS StreamWrapper. For us s3:// is defined as being โ€œthe root of the configured bucket plus any configured sub path prefixโ€ (this is different than if you have previously worked with the AWSSDK directly where you need to include the bucket name on each access).

    Should do it check for the existence of the bucket/directory on the remote S3 service instead?

    The s3fs_file table is considered and authoritative cache of the bucket status and is required to be kept up to date if making changes outside of the s3fs module (see README). While we call the internal decorated method, that method relies on standard PHP functions which are handled by the S3fsStream::class that routes back to the checking the s3fs_file table.

  • Status changed to Closed: cannot reproduce 9 months ago
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States cmlara

    More than 2 weeks without providing feedback closing the issue.

    If you are able to provide the requested information the issue may be re-opened.

Production build 0.71.5 2024