The file permissions could not be set on s3://videos/thumbnails/142.

I'm getting a ton of these. While some files actually upload others do not. Is there some sort of configuration that I'm missing either in the Module or on AWS S3?

Failed to create style directory: s3://styles/medium/s3/videos/thumbnails/142

I'm also getting these just once when I try to put things into a new folder, but the folder and the sub folders are all getting created on amazon.

I've tried with the beta5 and also with the latest dev (Nov 29).

From what I can tell drupal is passing chmod 436 and 509 (which are really strange octals).

Any ideas?

Comments

dlumberg’s picture

Version: 7.x-1.0-beta5 » 7.x-1.x-dev
Category: support » bug
StatusFileSize
new1.07 KB

The stream wrapper's chmod function wasn't taking into account that Amazon requires the trailing '/' for directories so it was failing any time the file module would try to chmod a directory.

patch attached.

diff --git a/sites/all/modules/amazons3/AmazonS3StreamWrapper.inc b/sites/all/modules/amazons3/AmazonS3StreamWrapper.inc
index be0e0a2..c1c3c36 100644
--- a/sites/all/modules/amazons3/AmazonS3StreamWrapper.inc
+++ b/sites/all/modules/amazons3/AmazonS3StreamWrapper.inc
@@ -195,13 +195,19 @@ class AmazonS3StreamWrapper implements DrupalStreamWrapperInterface {
     if(count($modes) != 3) {
       return FALSE;
     }
-    
+	
+	// Add handling of S3 directory structure
+    $localpath = $this->getLocalPath();
+	if ($this->_is_dir($localpath)){
+	 $localpath = $localpath . '/';
+	}
+	
     if(intval($modes[2]) >= 4) {
-      $response = $this->getS3()->set_object_acl($this->bucket, $this->getLocalPath(), AmazonS3::ACL_PUBLIC);
+      $response = $this->getS3()->set_object_acl($this->bucket, $localpath, AmazonS3::ACL_PUBLIC);
       return $response->isOK();
     }
     else {
-      $response = $this->getS3()->set_object_acl($this->bucket, $this->getLocalPath(), AmazonS3::ACL_PRIVATE);
+      $response = $this->getS3()->set_object_acl($this->bucket, $localpath, AmazonS3::ACL_PRIVATE);
       return $response->isOK();
     }
     
justafish’s picture

Assigned: Unassigned » justafish
Priority: Major » Normal
Status: Active » Needs review
StatusFileSize
new1023 bytes

Please verify the attached patch works for you. Thanks!

justafish’s picture

Status: Needs review » Closed (fixed)

Committed. Please reopen if there's any problems with it.

justafish’s picture

Issue summary: View changes

Adding blockquotes to hightlight error message