3

I am trying to use Shrine and fineuploader together to upload my files directly to S3.

The issue I am facing is that the Shrine gem's presign_endpoint is a GET request that returns a json response formatted like this:

{
  "url": "https://my-bucket.s3-eu-west-1.amazonaws.com",
  "fields": {
    "key": "b7d575850ba61b44c8a9ff889dfdb14d88cdc25f8dd121004c8",
    "policy": "eyJleHBpcmF0aW9uIjoiMjAxNS0QwMToxMToyOVoiLCJjb25kaXRpb25zIjpbeyJidWNrZXQiOiJzaHJpbmUtdGVzdGluZyJ9LHsia2V5IjoiYjdkNTc1ODUwYmE2MWI0NGU3Y2M4YTliZmY4OGU5ZGZkYjE2NTQ0ZDk4OGNkYzI1ZjhkZDEyMTAwNGM4In0seyJ4LWFtei1jcmVkZW50aWFsIjoiQUtJQUlKRjU1VE1aWlk0NVVUNlEvMjAxNTEwMjQvZXUtd2VzdC0xL3MzL2F3czRfcmVxdWVzdCJ9LHsieC1hbXotYWxnb3JpdGhtIjoiQVdTNC1ITUFDLVNIQTI1NiJ9LHsieC1hbXotZGF0ZSI6IjIwMTUxMDI0VDAwMTEyOVoifV19",
    "x-amz-credential": "AKIAIJF55TMZYT6Q/20151024/eu-west-1/s3/aws4_request",
    "x-amz-algorithm": "AWS4-HMAC-SHA256",
    "x-amz-date": "20151024T001129Z",
    "x-amz-signature": "c1eb634f83f96b69bd675f535b3ff15ae184b102fcba51e4db5f4959b4ae26f4"
  },
  "headers": {}
}

Fineuploader uses a signature endpoint that does a POST request therefore returning a "method not allowed" error.

var uploader = new qq.s3.FineUploader({
    request: {
        endpoint: '{ CDN_ENDPOINT_URL }'
        accessKey: '{ ACCESS_KEY }'
    },
    objectProperties: {
        bucket: '{ BUCKET_NAME }'
        host: '{ BUCKET_HOST_NAME }'
    },
    signature: {
        endpoint: '/presign'
    }
});

Is there a way to change fineuploader's signature method into a GET method or am I totally in the wrong direction ? Any advice in creating this feature is welcome.

I would like to do something similar to https://github.com/gorails-screencasts/shrine-direct-upload-to-s3/blob/master/app/assets/javascripts/uploads.js but with fine-uploader.

Snake
  • 1,157
  • 1
  • 10
  • 21

0 Answers0