mwishek / metalsmith-s3 Goto Github PK
View Code? Open in Web Editor NEWMetalsmith plugin for reading source files from S3
Metalsmith plugin for reading source files from S3
@mwishek - I'm getting the error:
TypeError: Error: InvalidParameterType: Expected params.ContentType to be a string
When attempting to use the plugin. I've tried setting the credentials using export and the config file but doesn't make any difference. My build file looks like this:
var metalsmith = require('metalsmith');
var markdown = require('metalsmith-markdown');
var layouts = require('metalsmith-layouts');
var less = require('metalsmith-less')
var htmlMinifier = require("metalsmith-html-minifier");
var uglify = require('metalsmith-uglify');
var s3 = require('metalsmith-s3');
metalsmith(__dirname)
.use(markdown())
.use(layouts({
'engine': 'handlebars',
'partials': 'partials'
}))
.use(less({
'pattern': 'less/styles.less'
}))
.use(htmlMinifier())
.use(uglify({
'removeOriginal': true,
'order': ['js/jquery.js','js/*.js'],
'concat': 'js/scripts.min.js'
}))
.use(s3({
action: 'write',
bucket: 'my-s3-bucket',
region: 'eu-west-1'
}))
.build(function(err) {
if (err) throw err;
});
The full error message is:
/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/request.js:30
throw err;
^
TypeError: Error: InvalidParameterType: Expected params.ContentType to be a string
at result (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/lib/index.js:206:11)
at /Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/lib/index.js:134:6
at /Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/lib/index.js:200:5
at done (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/async/lib/async.js:126:15)
at Response.<anonymous> (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/async/lib/async.js:32:16)
at Request.<anonymous> (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/request.js:354:18)
at Request.callListeners (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/request.js:596:14)
at Request.transition (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/request.js:21:10)
at AcceptorStateMachine.runTo (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/request.js:37:9)
at Request.<anonymous> (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/request.js:598:12)
at Request.callListeners (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at Request.emit (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/request.js:596:14)
at Request.transition (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/request.js:21:10)
at AcceptorStateMachine.runTo (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/request.js:34:11)
at Request.<anonymous> (/Library/WebServer/Documents/metalsmith-site/node_modules/metalsmith-s3/node_modules/aws-sdk/lib/request.js:598:12)
Thanks.
In the S3 online interface, my region is listed as "Oregon", which is us-west-2
My config is
{
action: 'write',
bucket: 'actualbucketname',
region: 'us-west-2'
}
yet I still get the error TypeError: Error: PermanentRedirect: The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
I was trying to figure out why none of my images were being copied as part of my metalsmith setup. I think I've tracked it down to the fact that the CopyS3Objects() function executes:
s3.listObjects(param, next);
But param.Bucket is set to config['bucket']
, so it's going to read the list of files to copy from the DESTINATION bucket.
Modifying the line to read s3.listObjects({Bucket: config['from']}, next);
gives me the desired behaviour.
Is this my misunderstanding of what the intended functionality is, or is it a bug?
Everytime I deploy my static site I get this exception at the end of the copy...
I'm using node 8.4.0 and aws-sdk 2.109.0.
/Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/request.js:31
throw err;
^
Error: Callback was already called.
at Response.<anonymous> (/Users/nicolas/projects/createu.rs/node_modules/metalsmith-s3/node_modules/async/dist/async.js:903:32)
at Request.<anonymous> (/Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/request.js:364:18)
at Request.callListeners (/Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
at Request.emit (/Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /Users/nicolas/projects/createu.rs/node_modules/aws-sdk/lib/state_machine.js:26:10
make: *** [build] Error 1
Howdy @mwishek - would you be able to bump the package.json version number and publish the current code to npm?
Thanks!
When a write operation is run on a Windows machine, it copies all of the files in sub directories to the root of the S3 bucket with backslashes in their name. For example if you are writing a file that has the Windows path:
\api\index.html
You would end up with a file in the root of your s3 bucket named literally "\api\index.html" including the backslashes in the filename.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.