-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass down specific properties to the client callback after the file is uploaded #86
Comments
I think it's an important feature to have. Maybe others can chime in / the package author. |
I do like the idea of the feature of returning meta data from the request. However callbacks should not have more than two arguments in order to keep the convention: As the key method on directive is specific to S3 and GoogleCloud, I would be in favour of a more generic name, Anyway, will need to figure out a neat way to fit this one in properly. |
@gsuess I agree on both - 2 arguments and name for the return data variable. I'll try to do a clean up soon and then send a PR. Btw, my fork only does it for S3 at present. |
This would be a pretty cool feature (well, for me it's more than just cool, it's actually needed), kinda sad it's open since almost a year. |
👍 |
I vote for it as well. At the moment I also have to parse the downloadUrl in order to figure out what I need to update in the collection. Will be looking forward to an update ;) |
I propose "extra" data could just be appended to the uploader object and used from there... I can get to some extra details already by lookin at the uploader, after upload: const uploader = new Slingshot.Upload('creativeUploads', creative);
uploader.send(file, (error, downloadUrl) => {
if (error) {
// Log service detailed response.
console.error('Error uploading', uploader.xhr.response);
throw error;
}
console.log('uploader complete', uploader, downloadUrl);
}); example of what it contains now (redacted a bit): {"file":{
"preview":"blob:http%3A//localhost%3A3000/186d57c7-4207-4606-8896-746a291de34f"
},
"instructions":{
"upload":"https://s3.amazonaws.com/c.example.com",
"download":"https://s3.amazonaws.com/c.example.com/x/H/z/xHz2G5WHeSM4TfQ5a-wt57354972537fd-thumb_large.jpg",
"postData":[
{
"name":"key",
"value":"x/H/z/xHz2G5WHeSM4TfQ5a-wt57354972537fd-thumb_large.jpg"
},
{
"name":"bucket",
"value":"example.com"
},
{
"name":"Content-Type",
"value":"image/jpeg"
},
{
"name":"acl",
"value":"public-read"
},
{
"name":"Content-Disposition",
"value":"inline; filename=\"wt57354972537fd-thumb_large.jpg\"; filename*=utf-8''wt57354972537fd-thumb_large.jpg"
},
{
"name":"x-amz-security-token",
"value":"xxxxxxx"
},
{
"name":"x-amz-algorithm",
"value":"AWS4-HMAC-SHA256"
},
{
"name":"x-amz-credential",
"value":"xxxxxxx/20160514/us-east-1/s3/aws4_request"
},
{
"name":"x-amz-date",
"value":"20160514T000000Z"
},
{
"name":"policy",
"value":"xxxxxxx"
},
{
"name":"x-amz-signature",
"value":"xxxxxxx"
}
]
},
"xhr":{ }
} |
Love the addon, looked at the source and I found it to be even better. I love the interface and the way it's laid out.
I have a few suggestions.
When files are uploaded, the client callback receives two variables
error
anddownloadUrl
. Is there a way we can send down a third variable called options which is anobject
for extra information we may need to update the meteor collection? For example if we want to generate the file name on the server, then we want to update the document with the file name instead of trying to parse the downloadUrl and extract the filename from there.Either that or make it so that the
metaContext
that is passed to the server can be passed on every upload. So in this methodthis.uploader.send(file, metaContext, function(error, downloadUrl) { ... });
The text was updated successfully, but these errors were encountered: