Skip to content

Commit

Permalink
Merge pull request #625 from vsychov/acl-skip
Browse files Browse the repository at this point in the history
Add WP_STATELESS_SKIP_ACL_SET for skip ACL set for GCS
  • Loading branch information
planv committed Oct 16, 2023
2 parents 269e8f0 + 4cbb1c7 commit 0e6ae5c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/classes/class-gs-client.php
Expand Up @@ -250,15 +250,22 @@ public function add_media($args = array()) {
// Reset to the client to execute requests immediately in the future.
$this->client->setDefer(false);
} else {
$media = $this->service->objects->insert($this->bucket, $media, array_filter(array(
$mediaOptions = array(
'data' => file_get_contents($args['absolutePath']),
'uploadType' => 'media',
'mimeType' => $args['mimeType'],
'predefinedAcl' => 'bucketOwnerFullControl',
)));
);

if ( !defined('WP_STATELESS_SKIP_ACL_SET') || !WP_STATELESS_SKIP_ACL_SET) {
$mediaOptions['predefinedAcl'] = 'bucketOwnerFullControl';
}

$media = $this->service->objects->insert($this->bucket, $media, array_filter($mediaOptions));
}

$this->mediaInsertACL($name, $media, $args);
if ( !defined('WP_STATELESS_SKIP_ACL_SET') || !WP_STATELESS_SKIP_ACL_SET) {
$this->mediaInsertACL($name, $media, $args);
}
} catch (Exception $e) {
return new WP_Error('sm_error', $e->getMessage());
}
Expand Down

0 comments on commit 0e6ae5c

Please sign in to comment.