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

Image upload failed - Amazon returned Http Code: 307 #3024

Closed
Baskerville42 opened this issue Jun 11, 2016 · 27 comments
Closed

Image upload failed - Amazon returned Http Code: 307 #3024

Baskerville42 opened this issue Jun 11, 2016 · 27 comments

Comments

@Baskerville42
Copy link

I configured S3 and when I try upload image I get this
2016-06-11 09 49 49
My AWS S3 credential all right 'cause I can upload files by using aws-cli
Thanks!

@jstockwin
Copy link
Contributor

@Baskerville42 What region is your S3 server in, and have you set S3_REGION?
For example, I have S3_REGION=eu-west-1 in my .env else it doesn't work.

@jstockwin
Copy link
Contributor

@Baskerville42 That looks exactly like the error I had when I didn't have my region set.
Where is your S3 server located?
Either add S3_REGION to your .env file, or include it in your keystone.set as

keystone.set('s3 config', { 
    bucket: 'my-bucket', 
    key: 'my-key', 
    secret: 'my-secret',
    region: 'my-region'
});

where my-region should be of the form eu-west-1.

@Baskerville42
Copy link
Author

Baskerville42 commented Jun 11, 2016

@jstockwin Oh, I missing this config (I mean S3_REGION) but it's not help =(
It's my .env file

S3_BUCKET=my-backet
S3_KEY=my-key
S3_SECRET=my-secret
S3_REGION=eu-central-1

@jstockwin
Copy link
Contributor

And you've restarted your keystone app and that still hasn't helped?

@Baskerville42
Copy link
Author

Yeah, after restarted it's not helped =(

@jstockwin
Copy link
Contributor

I don't see eu-central-1 on this list:
http://www.bucketexplorer.com/documentation/amazon-s3--amazon-s3-buckets-and-regions.html

You want to look at the S3 Endpoint column, but remove the preceding s3- and the proceeding .amazonaws.com (which is the last column in all but the EU one...)

@Baskerville42
Copy link
Author

@jstockwin
Copy link
Contributor

Hmm. See here http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
Notice that Frankfurt is version 4 only.

There's a comment over at #1267 suggests that we only support version 2, which is probably the problem...

Not sure why though... @keystonejs/core-devs ?

@Baskerville42
Copy link
Author

Change region to eu-west-1 and it's not helped too =(

@jstockwin
Copy link
Contributor

Ah, we're waiting for knox to support version 4. See Automattic/knox#254

Changing region isn't that simple though? You'll also have to make a new bucket in the correct region on S3, you can't just change the keystone config option.

@Baskerville42
Copy link
Author

Baskerville42 commented Jun 11, 2016

I created NEW bucket in eu-west-1 (Ireland) and it's not help me =(

@Baskerville42
Copy link
Author

Baskerville42 commented Jun 11, 2016

I can get access to my DO droplet, his created for test only.

@jstockwin
Copy link
Contributor

And you've changed the S3_BUCKET and S3_KEY etc to be correct for the one in eu-west-1?

@Baskerville42
Copy link
Author

Yeah

@jstockwin
Copy link
Contributor

And is it exactly the same problem? With the 307 error? You've restarted the server etc etc.

Not really sure what else to suggest here. It's working for me locally. Are you on Keystone 0.3 from npm, or 0.4 from current master?

@Baskerville42
Copy link
Author

I restarted app all time =)
package.json

{
  "name": "hmbia-landing",
  "version": "0.0.0",
  "private": true,
  "dependencies": {
    "keystone": "^0.3.16",
    "async": "^1.5.0",
    "underscore": "^1.8.3",
    "moment": "^2.10.6",
    "cloudinary": "^1.2.4",
    "express-handlebars": "^3.0.0",
    "handlebars": "^4.0.5",
    "node-sass": "^3.3.2",
    "node-sass-middleware": "^0.9.7",
    "dotenv": "^1.1.0"
  },
  "devDependencies": {
    "gulp": "^3.7.0",
    "gulp-shell": "^0.5.0",
    "gulp-watch": "^4.3.5",
    "gulp-sass": "^2.0.4"

  },
  "engines": {
    "node": ">=0.10.22",
    "npm": ">=1.3.14"
  },
  "scripts": {
    "start": "gulp"
  },
  "main": "keystone.js"
}

.env

COOKIE_SECRET=secret
MANDRILL_API_KEY=secret
S3_BUCKET=backet
S3_KEY=key
S3_SECRET=secret
S3_REGION=eu-west-1

@jstockwin
Copy link
Contributor

I assume S3_BUCKET=backet is intentional, and shouldn't say bucket?

If it's not that, then I'm afraid I'm stumped. If you only just created the bucket, sometimes it takes a while. Particularly if there used to be a bucket with the same name (if you deleted the one in eu-central and then created it again in eu-west, or just moved it if that's a thing). Maybe give it an hour or two then try again...

@Baskerville42
Copy link
Author

Ok. I'll wait for a while. Thanks!

@mxstbr
Copy link
Collaborator

mxstbr commented Jun 11, 2016

Hmm, I don't use the s3 field so I don't really have any clue what's going on here except everything that @jstockwin mentioned… 😕

@Baskerville42
Copy link
Author

After 6 hours I get another error - 400
2016-06-11 17 32 31

How I can enable debugger mode for more information? By using aws-cli tool I can upload files without any problems!

@jstockwin
Copy link
Contributor

Strange. 400 means bad request IIRC, but it's odd that it was giving you 307 earlier and now a 400.
Do you have any special characters in your key or secret? If so, perhaps generate a new key until it doesn't have special characters and try that.

Debugging depends on what you're using. I don't think there's a "debug mode" in keystone exactly, but if you add KEYSTONE_DEV=true to your environment that might help. Personally, I use Webstorm on Windows, so can set keystone_dev, and then just add breakpoints and click debug and it all plays nicely.

@Baskerville42
Copy link
Author

I solved a problem, thanks for help! =)

@jstockwin
Copy link
Contributor

@Baskerville42: Out of interest, what was the problem?

@Baskerville42
Copy link
Author

I not understand. All steps I make on digital ocean server. Then I try generate project on my Mac. And all was done.

@hari419
Copy link

hari419 commented Nov 7, 2017

hi, i'm trying to upload images to amazon s3 using keystonejs, but i'm facing issues
Profilepic upload failed - Amazon returned Http Code: 400

@ViswanathLekshmanan
Copy link

any update ? same 400 here

@hari419
Copy link

hari419 commented Dec 12, 2017

yes, the issue is resolved. bucket which you created in AWS s3 must be created with US region...
i have created bucket with AP region, so i'm getting error.
Create bucket with US region, it resolves the error...@ViswanathLekshmanan

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

5 participants