Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibilities of having S3 credentials under A post type for every User? #518

Closed
Boby opened this issue May 18, 2021 · 5 comments
Closed

Comments

@Boby
Copy link

Boby commented May 18, 2021

Hi,

I am trying to break down user to use credentials based on the post(each post will have each own secret key), and when user tries to upload it will reinit the instance with new credentials,

Does that means a rewrite or I can hook the _init and check based on postid?

thanks

@joehoyle
Copy link
Member

joehoyle commented May 18, 2021

@Boby you could conditionally set the S3_UPLOADS constants to user-specific values perhaps. This would look something like:

add_action( 'plugins_loaded', function () {
    if ( $_SERVER['REQUEST_URI'] === '/wp-admin/async-upload.php' && isset( $_POST['post_id'] ) ) {
        $access_key = get_post_meta( intval( $_POST['post_id'] ), 'aws_acces_key', true );
        define( 'S3_UPLOAD_ACCESS_KEY', $access_key );
    }
    
}, 9 ); // hook in before S3 Uploads is loaded

Or something along those lines. Doing it dynamically for S3-Uploads call (like if you needed to upload multiple images from different users in the same request), then that would be a little more tricky.

@Boby
Copy link
Author

Boby commented May 18, 2021

okay what I understand if we defined the key again to we need to ->get instance again? and setup? @joehoyle

@archon810
Copy link

@joehoyle What if I wanted to support multiple S3 endpoints, each with its own credentials, to store multiple files (say, files from 2021 are stored in one bucket, 2022 in a new one), and then the code needs to access some files from 2021 and 2022? As you said, dynamic would be a little more tricky, but what is the direction you'd recommend going in?

Perhaps there could be official support added for multi-endpoint feature? I imagine it could be a relatively common feature request.

Thanks.

@rmccue
Copy link
Member

rmccue commented Aug 18, 2022

We do not intend to add support for this, as we do not use or need this functionality. See our support policy: https://engineering.hmn.md/projects/support/

You're welcome to fork S3 Uploads and add the functionality to your own plugin though :)

@rmccue rmccue closed this as completed Aug 18, 2022
@rmccue rmccue closed this as not planned Won't fix, can't repro, duplicate, stale Aug 18, 2022
@archon810
Copy link

@rmccue #603 implements support for this. Please merge and reopen this ticket, then close as fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants