Twill: Imgix Integration using Local Storage

Created on 6 Mar 2019  路  19Comments  路  Source: area17/twill

Hello,

I am following the official instructions exactly and I can't get Twill to connect to my Imgix account.

Here are my .env variables:

MEDIA_LIBRARY_ENDPOINT_TYPE=local MEDIA_LIBRARY_LOCAL_PATH=uploads/ (this works as files are being written locally) IMGIX_SOURCE_HOST=jkh.imgix.net (accessible on the WWW) IMGIX_USE_SIGNED_URLS=true IMGIX_SIGN_KEY=xxxxx (Is this the Imgix 'API key' found in my account settings?)

Imgix Source Settings:

Base URL: http://darwin.test/uploads/ (confirmed working, e.g. I can access http://darwin.test/uploads/3b74e4bb-e506-4a57-a79c-d103f0f38b0c/photo-2019-02-28-09-37-59-3.jpg from my local machine)

imgix Domain: jkh.imgix.net

I really need to get this working ASAP so I'd appreciate any/all help.

Thanks

Jon

Most helpful comment

Woohoo!

image

All 19 comments

Hi @jkhamler,

The base URL you provide is based on your local environment. The images must be stored somewhere that imgix could access, thus you could either deploy your app to a WWW accessible server (then you can provide imgix with your base url, like: https://your-domain.com/), or use S3 instead (Related Twill documentation here)

Hope this helps!

Hi @yanhao-li. Yes, that makes sense... seems obvious now! I think S3 will be the way to go. Thanks for getting back to me.

@yanhao-li I'm having trouble connecting to S3 with Imgix. I've done everything exactly as per the docs, but I'm getting an upload error (no response body) resulting in a 307 temporary redirect response. Have you even seen this before?

Hi @jkhamler, it seems to be related to an S3 region misconfiguration: https://aws.amazon.com/premiumsupport/knowledge-center/s3-http-307-response/

@jkhamler No, I haven't, but this article maybe helpful

Thanks guys! Just trying to find the full URL for my region (EU/London) - I'm an S3 beginner.

eu-west-2

You can use S3_REGION or AWS_REGION or AWS_DEFAULT_REGION in your .env file to specify it 馃榾.

We've got progress!

image

Does my S3 policy also need to reference the region?

image

Cool! Now you're most likely facing an issue with either:

  • your API credentials
  • the CORS configuration of the bucket.

Nope, I don't think so, your policy looks good.

Ok cool.

So this stuff? What exactly is my admin domain in this context?

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <CORSRule>
        <AllowedOrigin>https://YOUR_ADMIN_DOMAIN</AllowedOrigin>
        <AllowedOrigin>http://YOUR_ADMIN_DOMAIN</AllowedOrigin>
        <AllowedMethod>POST</AllowedMethod>
        <AllowedMethod>PUT</AllowedMethod>
        <AllowedMethod>DELETE</AllowedMethod>
        <MaxAgeSeconds>3000</MaxAgeSeconds>
        <ExposeHeader>ETag</ExposeHeader>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
</CORSConfiguration>
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
    <CORSRule>
        <AllowedOrigin>https://admin.darwin.test</AllowedOrigin>
        <AllowedOrigin>http://admin.darwin.test</AllowedOrigin>
        <AllowedMethod>POST</AllowedMethod>
        <AllowedMethod>PUT</AllowedMethod>
        <AllowedMethod>DELETE</AllowedMethod>
        <MaxAgeSeconds>3000</MaxAgeSeconds>
        <ExposeHeader>ETag</ExposeHeader>
        <AllowedHeader>*</AllowedHeader>
    </CORSRule>
</CORSConfiguration>

Hi @ifox, admin.darwin.test is just my dev machine v-host address, shouldn't it be the imgix service?

@jkhamler your machine is sending the upload request to this S3 bucket.

Woohoo!

image

Thanks guys. I no longer want to throw my computer out of the window (well, not quite as much as I did 30 minutes ago)

Awesome, glad we were able to help out 馃槈

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Gummibeer picture Gummibeer  路  5Comments

vacoup95 picture vacoup95  路  3Comments

karneaud picture karneaud  路  3Comments

bastienrobert picture bastienrobert  路  7Comments

newvladimirov picture newvladimirov  路  3Comments