I need all files (public and private) uploaded to S3 to be private; so I implemented a very simple hook:

function my_module_s3fs_upload_params_alter(&$upload_params) {
  $upload_params['ACL'] = 'private';
}

The upload works but the hook is never called and the uploaded file ends up with "standard" ACL instead of "private".

Comments

captone created an issue. See original summary.

coredumperror’s picture

Are you certain the hook isn't being called? That looks like the right format for the function name, and the hook should be getting invoked on line 784 in S3fsStreamWrapper.inc, in the stream_flush() method:

    // Allow other modules to alter the upload params.
    drupal_alter('s3fs_upload_params', $upload_params);

If you have the devel module installed, I'd suggest putting a call to dd('hook triggered'); into your hook, then looking at /tmp/drupal_debug.txt after uploading a file, to see if "hook triggered" appears in there.

I'm also curious about the ACL you said that your files are getting. The docs don't mention an ACL called "standard". The only ones available are private | public-read | public-read-write | authenticated-read | bucket-owner-read | bucket-owner-full-control. And since "private" is the default, the only values you should be seeing on s3fs-uploaded files are "private" and "public-read".

captone’s picture

Status: Active » Closed (works as designed)

Sorry for the confusion but the issue isn't related to s3fs. The site is also running s3fs_cors, So the hook is not called because s3fs code is not executed to upload a file. I didn't check engough before creating this issue, assuming s3fs_cors was using upload code from s3fs, which is not the case.
My wording for the ACL was not precise enough. "standard" meant "public-read".