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

Using getFormPostParams #80

Open
KrunchMuffin opened this issue Jun 13, 2023 · 4 comments
Open

Using getFormPostParams #80

KrunchMuffin opened this issue Jun 13, 2023 · 4 comments

Comments

@KrunchMuffin
Copy link

I know it says TODO, but can you TODO it now? lol.
I am getting a signature mismatch and wondering if it's because I am not using this.

@jcberquist
Copy link
Owner

I am not sure what you are trying to do when you get the signature mismatch? This method is there to help with POSTing from a browser directly to S3, but I haven't thought in detail about the best way to make that available to people using the library (though I myself do use it in its current state extensively as is).

@KrunchMuffin
Copy link
Author

KrunchMuffin commented Jun 14, 2023 via email

@jcberquist
Copy link
Owner

Are you trying to do PUT or POST requests? This method is only for using POST. For example:

// in CFML

// Whatever form fields you intend to pass with the request go here
var formFields = [
    { name: 'acl', value: 'private' },
    { name: 'success_action_status', value: '201' },
    { name: 'Content-Type', value: 'application/pdf' },
    { name: 'Content-Disposition', value: 'attachment; filename="myfile.pdf"' },
    { name: 'name', value: 'myfile.pdf' }
];

formFields.append(
    aws.s3.getFormPostParams(
        'my_s3_bucket',
        'my_key', 
        formFields
    ),
    true
);

var formFieldsStruct = formFields.reduce( function( resultStruct, item ) {
    resultStruct[ item.name ] = item.value;
    return resultStruct;
}, { } );

// use these fields in a struct that could be serialized to JSON and returned to the client
var uploadParameters = { 
    method: 'POST', 
    url: 'https://my_s3_bucket.s3.amazonaws.com', 
    fields: formFieldsStruct, 
    headers: {} 
};

You could then use the uploadParameters in Uppy, it looks like: https://uppy.io/docs/aws-s3 - I haven't used Uppy myself, so this may require some tweaking to get it to work.

@KrunchMuffin
Copy link
Author

KrunchMuffin commented Jun 14, 2023 via email

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

2 participants