Code Monkey home page Code Monkey logo

Comments (7)

joevandyk avatar joevandyk commented on September 23, 2024

This works for me.

require 'rubygems'
require 'aws/s3'

s3 = AWS::S3.new(
    :access_key_id => "KEY",
    :secret_access_key => "SECRET",
    :s3_endpoint => 'localhost',
    :s3_port => '10003',
    :use_ssl => false,
)

bucket = s3.buckets['Bucket1']

obj = bucket.objects['key']
obj.write(File.open('/some/file/name/here'))

puts bucket.objects['key'].read

from fake-s3.

quanghoc avatar quanghoc commented on September 23, 2024

I was using this http://aws.amazon.com/sdkfornodejs/

I ran this command line in Windows 7

C:\s3>fakes3 -r c:\s3 -p 4567
Loading FakeS3 with c:/s3 on port 4567 with hostname s3.amazonaws.com
[2014-03-06 13:07:26] INFO  WEBrick 1.3.1
[2014-03-06 13:07:26] INFO  ruby 1.9.3 (2012-11-10) [i386-mingw32]
[2014-03-06 13:07:26] INFO  WEBrick::HTTPServer#start: pid=8104 port=4567

My code is this:

var AWS = require('aws-sdk'); 

var s3 = new AWS.S3({
    access_key_id: "KEY",
  secret_access_key: "SECRET",
  s3_endpoint: 'localhost',
  s3_port: '4567',
  use_ssl: false}
); 
s3.createBucket({Bucket: 'myBucket'}, function() {
  var params = {Bucket: 'myBucket', Key: 'myKey', Body: 'Hello!'};
  s3.putObject(params, function(err, data) {
    if (err)       
      console.log(err)     
    else
      console.log("Successfully uploaded data to myBucket/myKey");   
   });
});

And I got error as below. Any help?

{ [CredentialsError: Could not load credentials from any providers]
  message: 'Could not load credentials from any providers',
  code: 'CredentialsError',
  errno: 'ENETUNREACH',
  syscall: 'connect',
  time: Thu Mar 06 2014 16:14:33 GMT-0800 (Pacific Standard Time),
  originalError:
   { code: 'ENETUNREACH',
     errno: 'ENETUNREACH',
     syscall: 'connect',
     message: 'connect ENETUNREACH' },
  _willRetry: false }

from fake-s3.

georgeportillo avatar georgeportillo commented on September 23, 2024

I am too having this problem. How can I fix it? ^ I've tried adding the missing "credentials".

var AWS = require('aws-sdk');
var s3 = new AWS.S3();
var accessKeyId = process.env.AWS_ACCESS_KEY || "accesskey";
var secretAccessKey = process.env.AWS_SECRET_KEY || "secretkey";
AWS.config.update({
  accessKeyId: accessKeyId,
  secretAccessKey: secretAccessKey,
  region: 'us-west-1' // Missing? I never had to specify this before
});

from fake-s3.

tielur avatar tielur commented on September 23, 2024

@quanghoc @georgeportillo and for anyone else using the aws-sdk-js library. This is working for me:

var config = {
  accessKeyId: "123",
  secretAccessKey: "abc",
  endpoint: "localhost:3001",
  sslEnabled: false,
  s3ForcePathStyle: true
};
AWS.config.update(config);

var s3 = new AWS.S3({params: {Bucket: 'myBucket'}});

from fake-s3.

jiminikiz avatar jiminikiz commented on September 23, 2024

This error occurs when you pass in invalid credentials.

from fake-s3.

pickhardt avatar pickhardt commented on September 23, 2024

Closing because it seems this has been resolved - invalid credentials was the problem. If it wasn't, just let me know exactly what I should do to reproduce and I can look into it.

from fake-s3.

khessels avatar khessels commented on September 23, 2024

Just had the same thing, My uploaded content would be available like normal, but as soon as i would use the aws-sdk to manipulate files i would receive the same ENETUNREACH error. The whole day looking for a problem. Next day it magically started working again. Turns out that it was a problem with amazon.

Intresting...

from fake-s3.

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.