我正在尝试从 Node.js 应用程序将文件上传到我的 S3 存储桶,因此我正在遵循一些非常简单的教程,例如本教程。
代码非常简单:
const AWS = require("aws-sdk"); // fresh install, version : ^2.697.0
AWS.config.update({ // Credentials are OK
accessKeyId: process.env.s3_accessKeyId,
secretAccessKey: process.env.s3_secretAccessKey,
region: 'eu-central-1'
});
const s3 = new AWS.S3();
let params = {
// (some upload params, file name, bucket name etc)
};
s3.upload(params); // <-- crash with error: "s3.upload is not a function"
Run Code Online (Sandbox Code Playgroud)
我看了AWS官方文档,s3.upload()
似乎是这样。我不知道为什么会出现错误。
如果我console.log(s3.upload)
得到undefined
。
Node.js v13.11.0。
编辑
我最终使用了s3.putObject()
which 与 , 做了几乎相同的事情s3.upload() …
我希望所有文本都以'...'结尾,但它只适用于内部div:
div {
border: solid 2px blue;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
width: 40px;
}
Run Code Online (Sandbox Code Playgroud)
<div>Test test test test test test
<div>asdasdasdasdasd</div>
</div>
Run Code Online (Sandbox Code Playgroud)
是否有任何解决方案,以便外部div中包含的文本也得到'...'?
编辑:看起来像是一个chrome问题,但仍然可以解决下面的答案
我的 Elasticsearch (v5.4.1) 文档有一个_patents
这样的字段:
{
// (Other fields : title, text, date, etc.)
,
"_patents": [
{"cc": "US"},
{"cc": "MX"},
{"cc": "KR"},
{"cc": "JP"},
{"cc": "CN"},
{"cc": "CA"},
{"cc": "AU"},
{"cc": "AR"}
]
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试构建一个查询,该查询将仅返回其专利与国家/地区代码数组匹配的文档。例如,如果我的过滤器是,["US","AU"]
我需要返回所有US
在AU
. 排除具有US
但不具有AU
.
到目前为止,我已经尝试向我当前的工作查询添加一个“术语”字段:
{
"query": {
"bool": {
"must": [
// (Other conditions here : title match, text match, date range, etc.) These work
,
{
"terms": {
"_patents.cc": [ // I tried just …
Run Code Online (Sandbox Code Playgroud) 我使用Chrome进行开发,并且应用程序总是在那里快速加载。但是现在我尝试在Firefox上运行,加载过程花费了大约8秒钟,令人难以置信的暂停,甚至在加载过程中,甚至在图标集位置的预加载器都停止了一段时间。我已经使用性能mozila工具记录了加载过程,并多次调用了globalZoneAwareCallback
,GC
并多次调用了样式重新计算。我在chrome浏览器中得到了几乎相同的图片,只是样式没有重新编译那么多,但是为什么它比firefox这么快?是因为风格?如何修复Mozila中的载入效果?
在我的 Angular 应用程序中,如果我加载主页/
然后导航到,比如说/products
,它工作正常(它是一个延迟加载的模块)。但是如果现在我重新加载页面,浏览器会GET /products
调用服务器,结果是 404。
解决方案是发送index.html
,Angular 应用程序又回到了轨道上。所以在 Express 中我做了app.all("*", (req,res) => { res.sendFile("index.html") })
并且它有效。
如何在 Nest 中做同样的事情?
有一个@All
装饰器,但是给定组件中的每个控制器都处理一个子路由,例如@Controller("cats")
将匹配/cats
路由,所以如果我添加@All
这个控制器,它将只匹配/cats/*
,而不匹配*
。
我真的必须为此创建一个带有控制器的完整独立模块吗?这就是我所做的
@Controller() // Matches "/"
export class GenericController {
@All() // Matches "*" on all methods GET, POST...
genericFunction(){
console.log("Generic route reached")
}
}
Run Code Online (Sandbox Code Playgroud)
在我的主模块中:
@Module({
imports: [
ItemsModule, // Other routes like /items
GenericModule, // Generic "*" route last …
Run Code Online (Sandbox Code Playgroud) 使用Angular 4(typescript),我有以下HTML代码:
<div *ngIf="dataService.selected_markers.length == 0" id="tsnPasteContainer">
<form style="width: 100%; height: 100%">
<textarea id="tsn_list" style="width: 100%; height: 100%" type="text" name="tsn_list" placeholder="e.g. 2001311,2425302,2153542,2435974"></textarea>
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用以下内容将用户输入的数据输入textarea:
public parseTSNs(){
let tsnString = document.getElementById("tsn_list").value;
console.log("User inputted string: " + tsnString);
}
Run Code Online (Sandbox Code Playgroud)
该功能由按钮调用.
代码未编译,原因如下:
Property 'value' does not exist on type 'HTMLElement'
Run Code Online (Sandbox Code Playgroud)
这应该是一个简单的功能.我究竟做错了什么?W3schools"从textarea获取价值"显示'.value'作为必需的功能!
我必须从两个订阅中获取数据,但我总是得到第一个的数据.
我有一个数据共享服务:
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
@Injectable()
export class DataService {
private source = new BehaviorSubject<any>('');
data = this.source.asObservable();
constructor() { }
update(values: any) {
this.source.next(values);
}
}
Run Code Online (Sandbox Code Playgroud)
在离开搜索组件之前,我调用了update方法.
现在,我在结果组件上.我得到这样的共享数据:
constructor(private dataSvc: DataService,
private router: Router,
private rideStore: RideStore) { }
ngOnInit() {
this.getData();
}
getData() {
this.subscription = this.dataSvc.data.take(1).subscribe(
data => this.data = data ? data : undefined,
err => console.log(err),
() => this._isValid()
);
}
Run Code Online (Sandbox Code Playgroud)
我的问题是:我需要共享数据来订阅另一个observable.首先,我构建一个对象骑行并在我调用搜索方法之后
search() {
this.rideStore.searchRides(this.ride).subscribe(
rides …
Run Code Online (Sandbox Code Playgroud) 您好,我正在尝试为我的 SPA 添加更新功能,但似乎遇到了这个问题
blogsRouter.put('/:id', (request, response) => {
const body = request.body
const blog = Blog ({
title: body.title,
author: body.author,
url: body.url,
likes: body.likes,
userId: body.userId,
userName: body.userName
})
Blog.findByIdAndUpdate(request.params.id, blog)
.then(updatedBlog => {
response.json(updatedBlog.toJSON())
})
.catch(error => console.log(error))
})
Run Code Online (Sandbox Code Playgroud)
它捕获了这个错误
Performing an update on the path '_id' would modify the immutable field '_id'
Run Code Online (Sandbox Code Playgroud)
我不确定这里发生了什么,因为据我了解,我并没有尝试更新 _field ,如果我的方法试图自动执行此操作,那么更好的方法是什么?
嗨,这是一个有点奇怪的问题,我已经看到了与我想要的类似的效果,但不完全相同,不确定我想做的是否可能。我想要两个 div 堆叠在一起,下面的 div 内容仅在特定区域(光标周围)显示,有没有办法使 div 仅部分透明?或者还有其他方法可以达到这个效果吗?
javascript ×6
html ×4
angular ×3
css ×2
typescript ×2
amazon-s3 ×1
aws-sdk ×1
css3 ×1
express ×1
firefox ×1
mongodb ×1
mongoose ×1
nestjs ×1
node.js ×1
observable ×1
performance ×1
router ×1
rxjs ×1