2014-12-06 24 views
0

您知道如何在S3架構中添加用戶名嗎?流星 - 在s3路徑中添加用戶名

對於爲例:

 
- appname 
    - username 
    - image1.jpg 
    - image2.jpg 
    - ... 

我現在用的是驚人的CFS:S3包。 雖然它是服務器端,我認爲我不能使用Meteor.user(),即使在一個方法中,不是? 這裏我做什麼,但實際上不起作用:

 

image = new FS.Store.S3("image", { 
    accessKeyId: xxx, 
    secretAccessKey: xxx, 
    bucket: "appname", 
    folder: Meteor.call(getUser); 
}); 


Meteor.methods ({ 

    getUser: function() { 
     return Meteor.user(); 
    } 

}); 

感謝您的幫助

回答

0

好了,我不知道你使用的庫,但與節點aws-sdk你會做這樣的事情這樣的:

/* S3 object is initialized before with the correct credentials */ 

S3.putObject({ 
    Key   : "a/full/path/to/your/file.jpg", 
    Body  : new Buffer(blob, 'binary'), 
    Bucket  : "theNameOfYourBucket", 
    ContentType : 'image/jpeg', 
}); 

所以也許你應該key更換你的folder財產。

+0

謝謝你的回答,我會試試這個。 – user2967278 2014-12-08 00:31:24