[英]File upload with flow.js server get response 404
即時通訊使用flow.js將文件上傳到服務器,目前我僅上傳一個文件,並檢查我的上傳路線,如果我收到我發送的文件。
所以在有角度的一面,我有這樣的東西:
<div class="container">
<h1>flow image example</h1>
<hr class="soften"/>
<div>
<div class="thumbnail" ng-hide="$flow.files.length">
<img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&text=no+image" />
</div>
<div class="thumbnail" ng-show="$flow.files.length">
<img flow-img="$flow.files[0]" />
</div>
<div>
<span class="btn btn-primary" ng-hide="$flow.files.length" flow-btn flow-attrs="{accept:'image/*'}">Select image</span>
<span class="btn btn-primary" ng-show="$flow.files.length" flow-btn flow-attrs="{accept:'image/*'}">Change</span>
<span class="btn btn-danger" ng-show="$flow.files.length"
ng-click="$flow.cancel()">
Remove
</span>
</div>
<p>
Only PNG,GIF,JPG files allowed.
</p>
</div>
</div>
我沒有問題地注入了ng-flow模塊,然后在我的角度控制器端使用了如下的app.config:
app.config(['flowFactoryProvider', function (flowFactoryProvider) {
flowFactoryProvider.defaults = {
target: 'http://localhost:8080/upload',
permanentErrors: [404, 500, 501],
maxChunkRetries: 1,
chunkRetryInterval: 5000,
simultaneousUploads: 4
};
flowFactoryProvider.on('catchAll', function (event) {
console.log('catchAll', arguments);
});
// Can be used with different implementations of Flow.js
// flowFactoryProvider.factory = fustyFlowFactory;
}]);
感覺這邊至少在工作,因為我從服務器端收到錯誤,這是我得到的錯誤:
GET http://localhost:8080/upload?flowChunkNumber=1&flowChunkSize=1048576&flowCu…-1692jpg&flowFilename=1692.jpg&flowRelativePath=1692.jpg&flowTotalChunks=1 404 (Not Found)
最后我把它放在路由器中
router.post('/upload',multipartMiddleware ,function (req, res) {
flow.post(req, function(status, filename, original_filename, identifier) {
console.log('POST', status, original_filename, identifier);
if (ACCESS_CONTROLL_ALLOW_ORIGIN) {
res.header("Access-Control-Allow-Origin", "*");
}
res.status(status).send();
});
});
如果有人可以給我一個小費,為什么失敗我非常感謝:D
似乎正在向POST端點發出GET請求。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.