Comments (13)
Node/Express backend implementation, jic. I'm pretty sure this is working, though.
// Import required modules
var crypto = require('crypto'),
shasum = crypto.createHash('sha1'),
base64 = function(str){
var buf = new Buffer(str).toString('base64');
return buf;
};
// Setup AWS Variables
var S3_BUCKET_NAME = 'bucket',
S3_SECRET_KEY = process.env.AWS_SECRET_KEY,
S3_ACCESS_KEY = process.env.AWS_ACCESS_KEY;
// Export Express.js routes
module.exports = function(app) {
app.get('/api/admin/files/sign', function (req, res) {
var params = {
"name": req.query.name,
"size": req.query.size,
"type": req.query.type
};
// PUT request to S3 must start within 5 minutes
var expires = new Date();
expires.setMinutes(expires.getMinutes() + 5); // 5 minute later
var objectName = params.name,
amzHeaders = "x-amz-acl:public-read",
mimeType = params.type;
var bucketKey = "uploads/" + params.name; // directory/file path
var policy= {
expiration: expires,
conditions: [
{ bucket: S3_BUCKET_NAME },
{ acl: 'public-read' },
{ expires: expires },
{ success_action_status: '201' },
[ 'starts-with', '$key', '' ],
[ 'starts-with', '$Content-Type', '' ],
[ 'starts-with', '$Cache-Control', '' ],
[ 'content-length-range', 0, 524288000 ]
]
};
var policy64 = base64(JSON.stringify(policy));
var hash, hmac;
hmac = crypto.createHmac('sha1', S3_SECRET_KEY);
// change to 'binary' if you want a binary digest
hmac.setEncoding('base64');
// write in the text that you want the hmac digest for
hmac.write(policy64);
// you can't read from the stream until you call end()
hmac.end(function(){
// read out hmac digest
hash = hmac.read();
//console.log("The URL is", url);
console.log('file ' + params.type + ' signed expires ' + expires);
res.send({
"acl": "public-read",
"awsaccesskeyid": S3_ACCESS_KEY,
"bucket": S3_BUCKET_NAME,
"region": "us-west-2",
"Cache-Control": "max-age=259200, public",
//"AWSAccessKeyId": S3_ACCESS_KEY,
"Content-Type": params.type,
"expires": expires.toISOString(),
"key": bucketKey,
"policy": policy64,
"signature": hash,
"success_action_status": "201"
});
});
});
...
from ember-uploader.
"ember-uploader": "0.3.4"
in bower.json works, ember-uploader 0.3.5 breaks functionality. Is there a reason for this? If so, could you update the readme? Thanks!
from ember-uploader.
I will look into this. There was a change to the way the promise was resolved/rejected and I believe this is the culprit.
from ember-uploader.
Getting the same issue with 0.3.5
from ember-uploader.
If I had to guess, it looks like this change is the culprit: c5735be...3ffcef1#diff-7da8f6c08d157e1189a4f51cec1e5014R33
from ember-uploader.
c5735be...3ffcef1#diff-cd19b38f35e5030671d7f73532b875bdR36 *
from ember-uploader.
Can you try 2de1ba4
from ember-uploader.
Awesome 2de1ba4 worked 👍
from ember-uploader.
Oops, didn't notice your reply. Will test it out when I get back from class. ^^
from ember-uploader.
If it works for you, I'll go ahead and make a new build.
from ember-uploader.
Works like a charm! Sorry for the delayed response.
I didn't realize you could just bower install by commit. Pretty nifty. Thanks for looking into it. ^^
from ember-uploader.
Fixed in 2de1ba4
from ember-uploader.
New version has been released.
from ember-uploader.
Related Issues (20)
- Easy way to work with a presigned Url? HOT 2
- How get the file in API endpoint [RESOLVED]
- Style to look like drag and drop HOT 4
- Progress is always 100 HOT 4
- 400BadRequest on upload HOT 2
- Enable preventDefault HOT 2
- Start and stop not defined in unit tests
- arbitrary data attribute to file-upload component HOT 1
- Drag and drop does not work in IE HOT 2
- Add the option to skip form data insertion (won't change default functionality) HOT 3
- WHile uploading to S3 can we make the sign call with method 'POST' instead of 'GET"? HOT 1
- Ember 2.16/2.17 compatibility HOT 2
- DEPRECATION: An addon is trying to access project.nodeModulesPath.
- Looking for a maintainer. HOT 14
- Could not find module `@ember/version` imported from `ember-uploader/index` HOT 14
- Setting headers is not working HOT 3
- wrong variable (or need update doc) when you want to setting custom headers with extending s3 uploader HOT 5
- Authentication headers HOT 2
- Remove jQuery dependency HOT 2
- Is this package still maintained? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-uploader.