meteor mrt collectionfs deploy

时间:2013-10-01 11:31:26

标签: javascript meteor meteorite

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

我将使用collectionfs提供的大部分自述文件复制+粘贴到我的应用程序中,并添加了

{{cfsFileUrl "default1"}}

到我的文件列表。一切都在我的本地机器上运行。

当我使用

部署到???。meteor.com时出现问题
mrt deploy ???.meteor.com

我可以上传和下载图片,并且还会显示来自cfsFileUrl的网址

BUT:

当我访问该网址时,我收到错误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)
  }
});

1 个答案:

答案 0 :(得分:0)

我遇到了类似的问题并将其发布在collectionfs问题页面上。看看:https://github.com/CollectionFS/Meteor-CollectionFS/issues/85

相关问题