2

I am trying to upload files to s3 from ec2 using s3cmd from Frankfurt or Dublin instance:

s3cmd put -r folder  s3://bucket

However, I get:

ERROR: S3 error: 400 (InvalidRequest): The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.

I saw this question which recommends to set the config to V4 by doing:

signatureVersion: 'v4'

How can I do it with s3cmd command?

Community
  • 1
  • 1
Dejell
  • 12,840
  • 37
  • 129
  • 217

2 Answers2

4

You have to use the latest version 1.6.1

Just upgrade s3cmd the following way or any other way you might want to use.

pip install --upgrade
Istvan
  • 6,372
  • 7
  • 43
  • 81
  • my version is 1.1.0-beta3, however when I run sudo apt-get --only-upgrade install s3cmd, I get s3cmd is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 155 not upgraded. – Dejell Mar 03 '16 at 00:06
  • You are using outdated packages or an outdated operating system. Your original question is answered, if you do not know how to use your operating system ask it in a different question. – Istvan Mar 03 '16 at 07:12
  • It hasn't got to do with the OS. The linux repositories are not up to date: http://s3tools.org/download, therefore, the recommendation to upgrade will not work for that library - I will need to manually download it – Dejell Mar 03 '16 at 07:35
  • 1
    I see, in that case just install it with PIP. :) – Istvan Mar 03 '16 at 08:58
-1

I had the same issue. Region was Asia Pacific(Mumbai). Its actual region ap-south-1. Here is link http://docs.aws.amazon.com/general/latest/gr/rande.html Also configured AWSCLI using cmd aws configure set default.s3.signature_version s3v4 here is link http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingAWSSDK.html

Full workingCode here

var express = require('express');
var app = express();
var http = require('http').Server(app);
var fs = require('fs');
var aws = require('aws-sdk');
var S3FS = require('s3fs');

var s3fsImpl = new S3FS('ipxstorage/products', { accessKeyId:'Use your accesskey', secretAccesskey:'use your sck', region:'ap-south-1'});
var multiparty = require('connect-multiparty');
var multipartyMiddleware = multiparty();
aws.config.update({ signatureVersion:'v4'});

app.use(express.static(__dirname + '/public'));
app.set('views', __dirname+'/public/');
app.engine('html', require('ejs').renderFile);
app.use(multipartyMiddleware);

app.post('/upload', function(req, res){
    console.log(req.files.file);
    var file = req.files.file;
    var stream = fs.createReadStream(file.path);
    return s3fsImpl.writeFile(file.originalFilename, stream).then( function(){
        console.log('File Saved...');

        res.redirect('/')
    });
});


<form action="upload" method="POST" enctype="multipart/form-data">                    
                   <div class="file-field input-field">
                       <div class="btn"><span>Browse File</span><input name="file" type="file"></div>
                       <div class="file-path-wrapper">
                           <input class="file-path validate" type="text">
                       </div>

                   </div>                    
                   <button class="btn" type="Submit">Submit</button>
               </form>
Farhaan
  • 55
  • 4