- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 Angular 中使用 ng-flow 来针对 Express 后端上传单个图像。当我选择要上传的图像时,ng-flow 似乎正在向我的目标 (/admin/upload) 发送 GET 请求,然后什么也没有。我认为 GET 只是 testChunks 行为的一部分,但我仍然不清楚为什么我没有看到来自浏览器的 POST。
这是我的客户处理 ng-flow 的部分。它很大程度上基于 ng-flow 中的代码示例。
<div flow-init="{target: '/admin/upload'}" flow-prevent-drop
flow-drag-enter="style={border: '5px solid green'}"
flow-drag-leave="style={}"
test-chunks="false"
ng-style="style"
flow-files-submitted="$flow.upload()"
flow-file-success="$file.msg = $message">
<div class="container">
<h1>flow basic example</h1>
<hr class="soften"/>
<div class="row">
<div class="span6">
<h2>Buttons:</h2>
<span class="btn" flow-btn><i class="icon icon-file"></i>Upload File</span>
</div>
</div>
<hr class="soften">
<h2>Transfers:</h2>
<p>
<a class="btn btn-small btn-success" ng-click="$flow.resume()">Upload</a>
<a class="btn btn-small btn-danger" ng-click="$flow.pause()">Pause</a>
<a class="btn btn-small btn-info" ng-click="$flow.cancel()">Cancel</a>
<span class="label label-info">Size: {{$flow.getSize()}}</span>
<span class="label label-info">Is Uploading: {{$flow.isUploading()}}</span>
</p>
<table class="table table-hover table-bordered table-striped" flow-transfers>
<thead>
<tr>
<th>#</th>
<th>Name</th>
<th>Size</th>
<th>Relative Path</th>
<th>Unique Identifier</th>
<th>#Chunks</th>
<th>Progress</th>
<th>Paused</th>
<th>Uploading</th>
<th>Completed</th>
<th>Settings</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="file in transfers">
<td>{{$index+1}}</td>
<td>{{file.name}}</td>
<td>{{file.size}}</td>
<td>{{file.relativePath}}</td>
<td>{{file.uniqueIdentifier}}</td>
<td>{{file.chunks.length}}</td>
<td>{{file.progress()}}</td>
<td>{{file.paused}}</td>
<td>{{file.isUploading()}}</td>
<td>{{file.isComplete()}}</td>
<td>
<div class="btn-group">
<a class="btn btn-mini btn-warning" ng-click="file.pause()" ng-hide="file.paused">
Pause
</a>
<a class="btn btn-mini btn-warning" ng-click="file.resume()" ng-show="file.paused">
Resume
</a>
<a class="btn btn-mini btn-danger" ng-click="file.cancel()">
Cancel
</a>
<a class="btn btn-mini btn-info" ng-click="file.retry()" ng-show="file.error">
Retry
</a>
</div>
</td>
</tr>
</tbody>
</table>
<hr class="soften"/>
<div class="alert" flow-drop flow-drag-enter="class='alert-success'" flow-drag-leave="class=''"
ng-class="class">
Drag And Drop your file here
</div>
</div>
</div>
</div>
</div>
这是我的express.js 文件的摘录。您会注意到我为上传 URL 定义了 app.post 和 app.get 方法。
var express = require('express'),
favicon = require('static-favicon'),
morgan = require('morgan'),
compression = require('compression'),
bodyParser = require('body-parser'),
methodOverride = require('method-override'),
cookieParser = require('cookie-parser'),
session = require('express-session'),
errorHandler = require('errorhandler'),
path = require('path'),
config = require('./config'),
passport = require('passport'),
mongoStore = require('connect-mongo')(session);
var multipart = require('connect-multiparty');
var multipartMiddleware = multipart();
process.env.TMPDIR = 'tmp';
var flow = require('../../flow-node.js')('tmp');
/**
* Express configuration
*/
module.exports = function(app) {
var env = app.get('env');
if ('development' === env) {
app.use(require('connect-livereload')());
// Disable caching of scripts for easier testing
app.use(function noCache(req, res, next) {
if (req.url.indexOf('/scripts/') === 0) {
res.header('Cache-Control', 'no-cache, no-store, must-revalidate');
res.header('Pragma', 'no-cache');
res.header('Expires', 0);
}
if(path.extname(req.url) == '.js'){
res.set('Content-Type','text/javascript');
}
}
next();
});
app.use(express.static(path.join(config.root, '.tmp')));
app.use(express.static(path.join(config.root, 'app')));
app.set('views', config.root + '/app/views');
app.set('scripts', config.root + '/app/scripts');
app.set('bower_components', config.root + '/app/bower_components');
app.post('/admin/upload', multipartMiddleware, function(req, res) {
console.log('in POST...');
flow.post(req, function(status, filename, original_filename, identifier) {
console.log('POST', status, original_filename, identifier);
res.send(200, {
// NOTE: Uncomment this funciton to enable cross-domain request.
'Access-Control-Allow-Origin': '*'
});
});
});
app.get('/admin/upload', function(req, res) {
flow.get(req, function(status, filename, original_filename, identifier) {
console.log('GET', status);
res.send(200, (status == 'found' ? 200 : 404));
});
});
app.get('/admin/download/:identifier', function(req, res) {
flow.write(req.params.identifier, res);
});
}
我是否错过了 ng-flow 标记中的一些基本内容?或者 Express 中的东西?或者?预先感谢您。
最佳答案
我遇到了同样的问题,我找到的解决方案是设置 testChunks:false
flow-init="{target: url, testChunks:false}"
关于angularjs - ng-flow 发出 GET,但不发出 POST,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24968194/
我正在尝试实现 kotlin stateflow,但不知道它不起作用的原因。 当前输出: 验证34567 预期输出: 验证 34567 验证失败 package stateflowDuplicate
最近我发现了一个我无法理解的流行为。 问题描述 考虑这种情况:你有一个父 flow 并且在它的 collect 中,你将有一个“子”flow 并调用 .collect(),像这样: parentFlo
我想通过 UML2 事件图为以下事件建模: 执行操作 1。此操作产生两个输出参数: Object1和对象 2。 执行操作 2。此操作需要 Object2 作为输入参数。它不需要 Object1 作为输
在 Vaadin 8 中,您可以在 Tab(属于 TabSheet)上设置一个图标: tab#setIcon(...) 在 Vaadin Flow(目前使用 14.1)中,我不知道如何在 Tab(属于
有什么办法可以做到这一点吗?如果存储库仅在 .git/config 中包含 git-flow 指令(如 ),则该存储库是否被视为已初始化 .... [gitflow "branch"] mas
the 2nd collecting below does not collect until I remove the first one. also read from [Manuel Vi
在官方示例中,他们总是有 /* @flow */在页面顶部。现在这对现有项目来说很好,很有帮助,我想选择加入每个文件的流程。从头开始构建一个新项目我只想在任何地方进行流类型检查,而不必输入 /* @f
Vaadin 突然停止构建我的库并出现以下错误。我已经跳了 Vaadin 舞(还有很多其他的东西),但我现在没主意了。我尝试为生产构建库(但对于开发也失败了)。 我正在使用 Vaadin Flow。
我注意到很多人和例子都使用 Flows 作为 List<> 的包装器,例如像这样: @Query("SELECT * from some_model ORDER BY some_field") fun
Vaadin 突然停止构建我的库并出现以下错误。我已经跳了 Vaadin 舞(还有很多其他的东西),但我现在没主意了。我尝试为生产构建库(但对于开发也失败了)。 我正在使用 Vaadin Flow。
关闭。这个问题是opinion-based 。目前不接受答案。 想要改进这个问题吗?更新问题,以便 editing this post 可以用事实和引文来回答它。 . 已关闭 3 年前。 Improv
git flow init后,如何删除git flow模型? 如何从 .git/config 文件中删除所有相关配置? $ git flow init # force reset $ git flow
我运行了 git init 并在选择第一个分支时犯了一个错误。现在我想重新运行它来更改设置,但它再也不会问第一个问题。 Which branch should be used for bringing
我刚刚开始一份新工作,他们的代码管理一团乱。通常情况下这没什么问题,我可以应付,但在这个地方,情况就糟糕得离谱了。 他们使用 TFS...对此我无能为力。没有机会介绍 git,但我一直在阅读有关 gi
我的应用程序有更新问题。我不太明白 subview 之间的数据流是怎么回事。 这是我目前的结构 ViewModel:ObsebsrvableObject MainView 与 ObservedObje
为什么“flow check-contents”需要使用 < 将文件重定向到其中,而“flow suggest”则不需要?看起来 check-contents 应该假设命令行参数是要检查的文件路径。
最近我在 Git 中发现了工作流的三个概念: GitFlow GitHub 流程 GitLab 流程 我读过 the nice articles关于它,但我不太了解 GitLab Flow。 简单地说
我们刚刚改用 Hg Flow,但我们还没有弄清楚的一件事是如何最好地使用 Jenkins。理想情况下,我们将有一个构建和测试开发的作业,一个构建和测试默认作业和其他作业,这些作业在创建功能或发布分支时
将 Vaadin 12 与 FormLayout 一起使用和标签左侧的输入字段。 我想设置标签列的宽度。如何使用 Java API 实现这一点? 最佳答案 用于设置个人 FormItem标签宽度和/或
我正在使用 React-Flow 来可视化 React 中组件的树状层次结构。每当您在 React-Flow 中创建自定义节点时,您都可以像这样在树中使用它: ,我就可以做到这一点。 .有没有
我是一名优秀的程序员,十分优秀!