2015-10-14 20 views
0

我是流星的新手,我正在嘗試上傳一個圖像存儲在文件系統中,然後只顯示已加載的圖像。在流星中上傳和顯示圖像

我也創建我上傳這樣

var createThumb = function(fileObj, readStream, writeStream) { 
// Transform the image into a 10x10px thumbnail 
gm(readStream, fileObj.name()).resize('10', '10').stream().pipe(writeStream); 
}; 

Images = new FS.Collection("images", { 
stores: [ 
    new FS.Store.FileSystem("thumbs", { transformWrite: createThumb }), 
    new FS.Store.FileSystem("images", {path: "~/uploads"}) 
], 
filter: { 
    allow: { 
     contentTypes: ['image/*'] //allow only images in this FS.Collection 
    } 
} 
}); 

我有幾個問題的圖像的縮略圖,首先我想在那裏我可以存儲圖像的計算機上指定的路徑。我不知道我是怎麼做到的。我在該項目中創建了一個公用文件夾,並希望將圖像存儲在那裏。

當我開始做縮略​​圖的時候,它根本不起作用。我不確定這些圖片(包括原始圖片和縮略圖)是否都上傳了。

任何人都可以解釋或指向我一個很好的教程嗎?

+0

您是否收到一些您可以分享的錯誤? –

+0

是不是最好的教程,甚至沒有最好的10000哈哈,但它可以幫助你https://github.com/Ethaan/simple-uploadFS – Ethaan

回答

1

這裏有一些教程

,但下面這段代碼應該工作。

Images = new FS.Collection("images", { 
    stores: [ 
     new FS.Store.FileSystem("thumbs", { path: "~/public/thumbs", transformWrite: createThumb }), 
     new FS.Store.FileSystem("images", { path: "~/public/images" }) 
    ], 
    filter: { 
     allow: { 
      contentTypes: ['image/*'] //allow only images in this FS.Collection 
     } 
    } 
});