小编Yve*_* M.的帖子

AWS S3 - 使用正则表达式在 S3 中搜索文件的示例

如何使用正则表达式列出S3中的文件(在linux cli模式下)?我在 s3 存储桶中有文件,例如等sales1.txtsales2.txt当我运行以下命令时,没有显示任何内容。是否有一个命令可以使用正则表达式列出 S3 存储桶中的所有文件?

命令:

aws s3 ls s3://test/sales*txt
Run Code Online (Sandbox Code Playgroud)

预期输出:

sales1.txt
sales2.txt
sales3.txt
Run Code Online (Sandbox Code Playgroud)

amazon-s3 aws-cli

4
推荐指数
1
解决办法
1万
查看次数

TypeScript 中的“复合类型”

我记得在 TypeScript 中看到过一个特性,其中一个类型可以由另一种类型的属性以及它自己的属性组成。但我不确定我是否记得正确。考虑以下:

// type or interface
type X = {
  a: number
};

// type or interface
// composes properties from X ???
type XPlus = {
  [P: keyof X], // include properties from X
  b: boolean    // add a new property
};

// instance includes properties from both X and XPlus
const instance: XPlus = {
  a: 100,
  b: false
};
Run Code Online (Sandbox Code Playgroud)

这似乎有效,但我不确定它是否按照我的想法行事。是否存在这样的功能,如果存在,它叫什么?

typescript

4
推荐指数
1
解决办法
2012
查看次数

AppSync 和 GraphQL 枚举突变

我在 AppSync for GraphQL 中有以下架构

input CreateTeamInput {
    name: String!
    sport: Sports!
    createdAt: String
}

enum Sports {
    baseball
    basketball
    cross_country
}
type Mutation{
    createTeam(input: CreateTeamInput!): Team
}
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试通过 AWS Amplify 库执行查询时

export const CreateTeam = `mutation CreateTeam($name: String!, $sport: String!){
  createTeam(input:{name:$name, sport:$sport}) {
    id,
    name,
    sport
  }
}
`;

....

API.graphql(graphqlOperation(CreateTeam, this.state))
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:Validation error of type VariableTypeMismatch: Variable type doesn't match

如何更新我的代码以使用此枚举类型?

amazon-web-services graphql aws-appsync aws-amplify

4
推荐指数
1
解决办法
3854
查看次数

来自 hub.docker.com 的 Docker 镜像统计信息

我在 hub.docker.com 上有一个 docker 镜像。有没有办法找出谁在使用我的 docker 镜像或谁在拉它?hub.docker.com 可以提供的任何统计信息。

docker dockerhub

4
推荐指数
2
解决办法
2607
查看次数

如何将模式:“no-cors”添加到 XMLHttpRequest?

我是 JavaScript 新手。如何在 JavaScript 中添加 mode:no-cors到 myXMLHttpRequest中?

例如,对于这段代码:

var xhr = new XMLHttpRequest();
xhr.open("POST", yourUrl, true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.send(JSON.stringify({
    value: value
}));
Run Code Online (Sandbox Code Playgroud)

javascript xmlhttprequest cors

4
推荐指数
1
解决办法
2万
查看次数

在 Express 应用程序配置中禁用会话

我正在将 Express 和 Passport 用于 Node.js API 应用程序,我可以通过传递{session:false}到来禁用会话passport.authenticate,但是有没有一种方法可以在一个地方执行此操作,这样我就不会重复 600 次?

var app = express();

app.configure(function() {
    app.use(express.bodyParser());
    app.use(passport.initialize());
});

app.get('/users', passport.authenticate('hash', {session:false}), controllers.users.getAll);
app.get('/users/me', passport.authenticate('hash', {session:false}), controllers.users.getCurrentUser);
// and so on...
Run Code Online (Sandbox Code Playgroud)

如果我能做到,那就太好了:

app.donotuse(sessions).thanks();
Run Code Online (Sandbox Code Playgroud)

node.js express passport.js

3
推荐指数
1
解决办法
4463
查看次数

将现有 Git 存储库迁移到启用 Git LFS 的新存储库

我现有的 Github 存储库因 zip 和 tar.gz 文件而变得臃肿,因此我想将其迁移到启用了 Git LFS 的新存储库,该存储库与现有的 Github 存储库分开进行测试,以便现有的 Github 存储库不受影响。我遇到了一个很棒的工具,名为 bfg-repo-cleaner https://github.com/rtyley/bfg-repo-cleaner,看起来正是我需要的!

我编制了我认为需要执行的步骤,但希望有第二双眼睛来确保这些步骤是正确的。

原始现有存储库在哪里https://github.com/username/source.git,启用 Git LFS 的新目标存储库在哪里https://github.com/username/destination-lfs.git

pass=PERSONAL_ACCESS_TOKEN
ORIGINAL="https://github.com/username/source.git"
REPONAME_ORIGINAL='source.git'
NEW="https://username:"${pass}"@github.com/username/destination-lfs.git"
REPONAME_NEW='destination-lfs.git'

# setup local work space
mkdir -p /home/workgit
cd /home/workgit

# download bfg
wget -cnv http://repo1.maven.org/maven2/com/madgag/bfg/1.12.12/bfg-1.12.12.jar -O bfg.jar
alias bfg='/bin/java -jar bfg.jar'

# setup local git
git clone --mirror "$ORIGINAL" "$REPONAME_NEW"
cd $REPONAME_NEW
git count-objects -v
git remote rename origin upstream
git remote add origin $NEW
git …
Run Code Online (Sandbox Code Playgroud)

git github git-rewrite-history bfg-repo-cleaner

3
推荐指数
1
解决办法
3058
查看次数

在drawImage中使用ImageData对象

是否可以使用ImageData数组对象来获取 Image() 对象。我的最终目标是使用drawImage而不是putImageData因为putImageData太慢(来自 stackoverflow 类似的 qs 和我自己的测试)。我所拥有的只是ImageData要在画布上的现有图像之上绘制的数组。

javascript putimagedata

3
推荐指数
1
解决办法
5778
查看次数

从AWS lambda @ edge访问原始URL

我正在尝试使用AWS Cloudfront上的lambda @ edge对多个网站实施“代理”。

我的设置大致是:

DNS:*。domain.com-> some_uuid.cloudfront.net(Cloudfront发行版)

Cloudfront:some_uuid.cloudfront.net-> S3存储桶来源

s3存储桶:网站/(包含多个网站的文件夹)

lambda @ edge函数:定义为起点请求

我的lambda @ edge函数非常简单:

  1. 检查网站资源是否在s3存储桶中。

  2. 如果是,请将请求uri更改为资源s3 url。

  3. 如果不是,则向后端服务器发送请求以渲染资源,将其存储在s3上并返回。

我在获取网站的原始域时遇到问题。例如,如果我尝试访问“ my_website.domain.com”,则在我的lambda函数中,我没有请求中的该域信息。

我认为我可以实现另一个lambda @ edge函数作为查看器请求,以将域作为标头传递,但是如果可以的话,我宁愿避免这种情况。

还有其他解决方案吗?

谢谢

javascript node.js amazon-cloudfront aws-lambda aws-lambda-edge

3
推荐指数
2
解决办法
1233
查看次数

请推荐一个用于将IPTC数据写入图像的Node模块?

我有一个 Node.js 服务器,它的工作是下载 JPEG 图像,将某些数据写入几个 IPTC 字段(例如Iptc.Application2.Caption)并将图像传递给另一个服务。

理想情况下,我想将 IPTC 数据写入内存缓冲区(而不将图像写入本地文件系统)。如果做不到这一点,我可以采用一种解决方案,在该解决方案中我下载、将文件存储到 FS,然后应用 IPTC 数据。

我已经使用https://github.com/dberesford/exiv2node 进行了这项工作,但它不适用于 Node.js v10。而且它依赖于exiv2 C++ 库,这使得运行容器化变得很麻烦。

所以我的问题是:是否有一个像样的 Node.js 模块可以实现 IPTC 数据写入,并且不依赖于某些怪物 C 库?

iptc exif image node.js

3
推荐指数
1
解决办法
1375
查看次数