我试图获取我使用collectionFS上传的文件的网址。
Images.insert(file, function (err, fileObj) {
if (err) {
console.log(err);
} else {
console.log('success', fileObj);
setTimeout(function () {
console.log('url', fileObj.url());
}, 2000);
}
});
目前fileObj.url()
会返回cfs/files/images/....
,但我有一个这样的自定义路径:
Images = new FS.Collection("images", {
stores: [new FS.Store.FileSystem("images", {path: '/home/user/imagesupload'})]
});
上传图片时如何获得此路径?
答案 0 :(得分:1)
您设置的路径是服务器本地文件系统上的路径,而不是您想要从外部访问它的URL,如果您想使用自定义URL前缀而不是标准cfs,则需要使用setbaseurl命令:FS.HTTP.setBaseUrl('/home/user/imagesupload');