Giter Site home page Giter Site logo

Comments (5)

domenic avatar domenic commented on August 17, 2024

I never specify an endpoint, and everything works great to me. What setup are you using that you are constantly getting 307s? Something about regions? I'd appreciate more info.

Also, 307 is not a success code:

This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request.

Only 2xx class codes indicate success, so nothing outside that range should be treated as such. Perhaps that is what really needs to be specified better in the README.

from knox.

boutell avatar boutell commented on August 17, 2024

What region is your bucket in? I bet it's in us-standard, so the endpoint you're getting by default is already the final one.

If you try to use the default endpoint with a bucket that lives in the US Oregon region (us-west-2), you get a 307 redirect pointing you there. Which would be OK except that the putFile() function (and the putStream function it depends on) doesn't resolve that automatically. Your callback is invoked without an error, but your file hasn't been uploaded. Without an error it looks like you're done, and confusion ensues.

One possible solution is for putStream to follow the redirect. But if putStream isn't going to follow the redirect and complete the job, then it should be documented that you can bypass all this pain just by specifying the right endpoint in the first place, like this:

knox.createClient({
key: process.env.S3_KEY,
secret: process.env.S3_SECRET,
bucket: 'mybucket',
endpoint: 'mybucket.s3-us-west-2.amazonaws.com'
});

Note that the endpoint option, if specified, requires you to include the bucket name in the endpoint hostname yourself, since that is otherwise prepended as part of generating the default value for the endpoint option.

FYI, I'm using a region other than the default us-standard region because I need read-after-write consistency, without which there's no certainty people can see the file as soon as AWS claims they have it. But of course folks in Europe and elsewhere have an even more compelling need to do so.

from knox.

boutell avatar boutell commented on August 17, 2024

A 'region' option would be a nice alternative to assembling the endpoint hostname manually.

from knox.

domenic avatar domenic commented on August 17, 2024

OK, I agree we should make this easier. A region option sounds good, and a pull request is welcome. Eventually we'll take care of this by fixing #66.

from knox.

domenic avatar domenic commented on August 17, 2024

Fixed as part of #108.

from knox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.