0

I am trying to set up a simple S3 server I can pull a url (in this case it will be a Quickbase file that's been imported already), and by clicking a button will call a script stored in the Quickbase pages that will post to S3 with a tag field I defined, for simplicity's sake it's the dbid and record id# that's in a div field as its data that's pulled into the script as

var fileToUpload = $(this).attr('data');
var qbfiletag = $(this).attr('data');

Files to upload has the url exact that Quickbase is storing the file I need to import.

I know this is possible because the Juice and Zapier teams have done it, I am just having a hard time setting up the credentials to do this as a url.

I am not even 100% sure I set up the access key correctly. I did give read write access to mycompany.quickbase.com but other then that I have so much information for all the various that aws offers its hard to narrow down where I screwed up.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Just to be clear, is the goal here to push a button on a Quickbase form that leads to a document associated with that record being stored on your S3 server? – Nathan Hawe Aug 01 '16 at 18:07
  • pushing a button on the Quickbase form that retrieves the file from Quickbase and store it on the s3 server. – Robert Pratt Aug 02 '16 at 21:09

1 Answers1

0

It looks like there are several steps to setting up your account to access S3 through JavaScript. After your bucket is created, you need to setup CORS by accessing the properties of the bucket and choosing to edit the CORS configuration. You mentioned giving read/write access to your company's domain so you have probably already done this. I used this one from Amazon to test:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>https://mycompany.quickbase.com</AllowedOrigin>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <AllowedMethod>DELETE</AllowedMethod>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>

The second part is to create an IAM user in the Identity and Access Management Console. In the process of creating the user, Amazon will generate an access key ID and secret access key pair automatically. You'll need these for the API call later. You also need to attach a policy that establishes permissions for the user. I used the AmazonS3FullAccess policy for my test. All of this is done through that console.

Once your IAM user is setup you can pass the access key id and secret access key to the AWS configurator before instantiating the S3 object using the JavaScript SDK from Amazon.

AWS.config.update({accessKeyId: 'ABCDEFGHIJKLMNOP', secretAccessKey: 'a1b2c3d4e5f6g7i8j9k0+0012ab'});
var bucket = new AWS.S3({params: {Bucket: 'myBucketName'}});

From there you can use the bucket object to call any of the S3 methods in the SDK including uploading your file.

Community
  • 1
  • 1
Nathan Hawe
  • 281
  • 3
  • 5
  • I tried to post from within quickbase and was having cross domain issues. So instead I will use something like the please.js from GH to post a message containing data needed for a reference from QB to pull the correct file. I tried to use [this](http://stackoverflow.com/questions/17585881/amazon-s3-direct-file-upload-from-client-browser-private-key-disclosure/31055652#31055652) format for posting. And I am having issues with the Access-Control-Allow-Origin, I am not sure how to declare that on the website I know I have it correct on the cors doc – Robert Pratt Aug 08 '16 at 18:22
  • If you're still having cross-domain issues, that's a good indication that CORS is not setup correctly. Have you tried getting Amazon's example for uploading data to an object to work before adapting it to the specific needs of your project? If not, I suggest trying the example and working through the CORS and authentication issues with code that is known to work. That's how I tested my answer above. http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/browser-examples.html#Amazon_S3 – Nathan Hawe Aug 11 '16 at 15:58