将我的反应前端的文件发布到节点后端.
request
.post('/api/upload')
.field('fileName', res.body.text)
.field('filePath', `/${this.s3DirName}`) // set dynamically
.attach('file', data.file)
.end((err2, res2) => {
if (err2){
console.log('err2', err2);
this.setState({ error: true, sending: false, success: true });
}else{
console.log('res2', res2);
this.setState({ error: false, sending: false, success: true });
}
});
Run Code Online (Sandbox Code Playgroud)
然后在我的节点后端我想上传到s3.我正在使用busboy来获取发布的多部分文件,然后将aws sdk发送到我的s3存储桶.
var AWS = require('aws-sdk');
const s3 = new AWS.S3({
apiVersion: '2006-03-01',
params: {Bucket: 'bucketName'}
});
static upload(req, res) {
req.pipe(req.busboy);
req.busboy.on('file', (fieldname, file, filename) => {
console.log("Uploading: " + filename);
console.log("file: ", file);
var params = { …
Run Code Online (Sandbox Code Playgroud) 我想以二进制形式将图像发布到我的 Express 应用程序。
我假设它应该通过 req.body
对象中但需要某种形式的中间件才能处理二进制数据?
当我从邮递员发送二进制图像并尝试记录 req.body 时,对象为空。
我使用 express-generator 作为锅炉板,body-parser
如下所示:
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
Run Code Online (Sandbox Code Playgroud)
我看了一下 Multer,但认为这仅适用于多部分数据
还看了busboy,但不知道它是否会处理二进制数据。
我是否正确地认为帖子数据仍会在 req.body 中通过?我需要什么中间件来处理二进制数据?
谢谢
试图在我的bitbucket管道构建中运行npm测试脚本并且所有测试都通过但是只是挂起并且不会移动到下一个脚本.
所以我的测试脚本是: "test": "mocha src/**/*.spec.ts --require ts-node/register --reporter spec",
这是在我的bitbucket-pipelines.yml
文件中调用
- yarn install
- yarn run test
- yarn run prestart:prod
Run Code Online (Sandbox Code Playgroud)
所以纱线安装运行,纱线测试运行,但然后挂起并运行prestart:prod永远不会运行.
有什么理由它会挂起来吗?我需要设置--watch=false
还是其他什么?
我正在尝试使用 DTO 为 Nest.js 中的控制器定义我的数据。
我正在学习教程
我已经在其中创建了我的 DTO src/controllers/cats/dto/create-cat.dto.js
export class CreateCatDto {
readonly name: string;
readonly age: number;
readonly breed: string;
}
Run Code Online (Sandbox Code Playgroud)
不过,我对如何将其导入应用程序感到困惑。文档实际上并没有说明它需要导入,所以我认为 nest 在幕后做了一些魔术?尽管我有一种感觉,但事实并非如此。
我想直接在我的控制器中导入它:
import { CreateCatDto } from './dto/create-cat.dto';
Run Code Online (Sandbox Code Playgroud)
但这会引发错误:
Unexpected token (2:11)
1 | export class CreateCatDto {
> 2 | readonly name: string;
| ^
3 | readonly age: number;
4 | readonly breed: string;
5 | }
Run Code Online (Sandbox Code Playgroud)
DTO 代码是直接从嵌套文档中删除的,因此代码不应该存在问题(尽管readonly name: string;
看起来不像我以前遇到的 javascript)。
作为参考,这是我尝试使用 DTO 的猫控制器的其余部分
import { Controller, Bind, Get, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将背景视频设置为全屏。
我可以做到这一点height: 100vh;
和width: 100%;
,但只要从16比例的变化:9,我开始变得空白。
我也尝试过使用 objectobject-fit: cover;
但这似乎到处都是,我很难控制它。它也没有得到广泛支持(IE 11 和 edge 15 不支持它)。
我不确定我是否也在使用 bootstrap 4 使事情复杂化。
我的 HTML 是这样布局的
<div class="container-fluid home-page">
<video playsinline autoplay muted loop poster="polina.jpg" id="bgvid">
<source src="/wp-content/themes/_underscores/assets/Placeholder-Video.mp4" type="video/mp4">
</video>
<div class="row clients">
<div class="client-slider col-12">
<?php foreach($clients as $key => $client) : ?>
<div class="client-logo" style="background-image: url(<?php echo $client->featured_image; ?>)"></div>
<?php endforeach; ?>
</div>
</div>
<div class="row">
<div class="col-md-6 col-xs-12 info-text">
<h3>Title</h3>
<p>Content....</p>
<a href="#" class="button blue no-margin">SEE HOW IT …
Run Code Online (Sandbox Code Playgroud) 我已经克隆了一个项目,并尝试在设备(iPhone 7)上运行我的应用程序,但是它显示了构建失败,并带有以下提到的错误。
注意:如果我用Xcode创建一个新项目,则可以在我的设备上运行该应用程序。
我该如何解决?
Failed to create provisioning profile.
The app ID "org.reactjs.native.example.app" cannot be registered to your development team. Change your bundle identifier to a unique string to try again.
No profiles for 'org.reactjs.native.example.app' were found
Xcode couldn't find any iOS App Development provisioning profiles matching 'org.reactjs.native.example.app'.
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Jest来测试我的节点API.我有一个简单的npm脚本调用jest
{
"scripts": {
"start": "node server.js",
"dev": "nodemon server.js",
"test": "jest",
"precommit": "lint-staged"
},
"dependencies": {
"@koa/cors": "^2.2.1",
"apollo-link-http": "^1.5.4",
"apollo-server-koa": "^1.3.6",
"axios": "^0.18.0",
"dotenv": "^6.0.0",
"graphql": "^0.13.2",
"graphql-tools": "^3.0.4",
"koa": "^2.5.1",
"koa-bodyparser": "^4.2.1",
"koa-router": "^7.4.0",
"node-fetch": "^2.1.2"
},
"devDependencies": {
"husky": "^0.14.3",
"jest": "^23.3.0",
"lint-staged": "^7.2.0",
"nodemon": "^1.17.5",
"prettier": "^1.13.7"
},
"lint-staged": {
"gitDir": "./",
"*.{js,json}": [
"prettier --no-semi --print-width 140 --tab-width 2 --write",
"git add"
]
},
"jest": {
"bail": true,
"verbose": true,
"testMatch": [
"<rootDir>/**/*.test.js"
] …
Run Code Online (Sandbox Code Playgroud)