2013-10-01 35 views
0

我使用collectionfs在我的应用程序中存储文件。meteor mrt collectionfs deploy

我复制粘贴+最具备collectionfs到我的应用程序的自述代码,也加入

{{cfsFileUrl "default1"}} 

我的文件清单。一切工作在我的本地机器上。

的问题出现了,当我部署到??? meteor.com与

mrt deploy ???.meteor.com 

我可以上传和下载图像,也是一个URL来自cfsFileUrl显示,

但是:

当我访问该网址时,我收到错误404.

我的代码: client.html

<body> 
    {{loginButtons}} 
    {{>queueControl}} 
    <br>ta 
    <br> 
    {{>fileTable}} 
</body> 

<template name="queueControl"> 
    <h3>Select file(s) to upload:</h3> 
    <input name="files" type="file" class="fileUploader" multiple> 
</template> 

<template name="fileTable"> 
    {{#each files}} 
    {{cfsDownloadButton "ContactsFS" class="btn btn-primary btn-mini" content=filename}}<br> 
     <img src="{{cfsFileUrl "default1"}}"> 
    {{/each}} 
</template> 

client.js

ContactsFS = new CollectionFS('contacts', { autopublish: false }); 

Deps.autorun(function() { 
    Meteor.subscribe('myContactsFiles'); 
}); 

Template.queueControl.events({ 
    'change .fileUploader': function (e) { 
     var files = e.target.files; 
     for (var i = 0, f; f = files[i]; i++) { 
      ContactsFS.storeFile(f); 
     } 
    } 
}); 

Template.fileTable.files = function() { 
    //show all files that have been published to the client, with most recently uploaded first 
    return ContactsFS.find({}, { sort: { uploadDate:-1 } }); 
}; 

server.js

ContactsFS = new CollectionFS('contacts', { autopublish: false }); 

Meteor.publish('myContactsFiles', function() { 
    if (this.userId) { 
     return ContactsFS.find({ owner: this.userId }, { limit: 30 }); 
    } 
}); 

ContactsFS.allow({ 
    insert: function(userId, file) { return userId && file.owner === userId; } 
}); 

ContactsFS.fileHandlers({ 
    default1: function(options) { // Options contains blob and fileRecord — same is expected in return if should be saved on filesytem, can be modified 
    console.log('I am handling default1: ' + options.fileRecord.filename); 
    console.log(options.destination()); 
    return { blob: options.blob, fileRecord: options.fileRecord }; // if no blob then save result in fileHandle (added createdAt) 
    } 
}); 

回答