小编Ars*_*ene的帖子

ASP.NET Web API 2文件上载

我想知道如何最好地处理文件上传和添加到要使用没有MVC组件的ASP.NET Web API 2上载的文件的附加信息.我有谷歌网,我可以告诉你我比我想象的更困惑.

附加信息将存储在db中,文件存储在磁盘上.到目前为止,我正在构建的Web API应用程序不支持multipart/form-data.它仅支持默认媒体类型.我知道我需要创建一个媒体格式化程序.

请帮忙.

asp.net asp.net-web-api2

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

Logback 和 SLF4J 编程配置

我在基于 tomcat 的 Web 应用程序中使用 Logback 和 SLF4J。我没有使用任何 logback.xml 文件。一切都以编程方式完成。但是,我不时收到以下错误消息:

java.lang.ClassCastException: org.slf4j.helpers.SubstituteLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext.
Run Code Online (Sandbox Code Playgroud)

这是引发该异常的代码部分:

LoggerContext logCtx = (LoggerContext) LoggerFactory
                .getILoggerFactory();
Run Code Online (Sandbox Code Playgroud)

我想知道我是否做错了什么。请协助。

java logback slf4j

5
推荐指数
1
解决办法
1852
查看次数

NestJs JWT 身份验证返回 401

我已经在 nestJs 中实现了 jwt 身份验证。但是,每当我尝试使用以下授权标头进行身份验证时:

Bearer <token> or JWT <token>
Run Code Online (Sandbox Code Playgroud)

我得到了 401。这些是我的身份验证文件

@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy, 'jwt') {
  constructor(private readonly authService: AuthService) {
    super({
      jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
      secretOrKey: `${process.env.SECRET}`,
    });
  }

  async validate(payload: Credentials) {
    const user: Account = await this.authService.validateAccount(payload);
    if (!user) {
      throw new UnauthorizedException();
    }
    return user;
  }
}


@Injectable()
export class JwtAuthGuard extends AuthGuard('jwt') {
  canActivate(context: ExecutionContext) {
    return super.canActivate(context);
  }

  handleRequest(err, user, info) {
    if (err || !user) {
      throw err || new UnauthorizedException(); …
Run Code Online (Sandbox Code Playgroud)

jwt typescript nestjs nestjs-passport nestjs-jwt

5
推荐指数
1
解决办法
8977
查看次数

使用环境文件进行NestJs TypeORM配置

我有两个.env文件,例如dev.envstaging.env。我正在使用typeorm作为我的数据库ORM。我想知道每当我运行应用程序时如何让typeorm读取其中一个配置文件。Error: No connection options were found in any of configurations file来自typeormmodule。

javascript node.js typescript typeorm nestjs

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

如何使用github.com/jhump/protoreflect 解析一个字节数组的proto消息知道消息描述符

我有一个包含以下 protomessage 字节片段的文件。

syntax = "proto3";

package main;

message Address {
    string street = 1;
    string country = 2;
    string state = 3;
}
Run Code Online (Sandbox Code Playgroud)

我的消息类型描述如下:

syntax = "proto3";

package main;

message Address {
    string street = 1;
    string country = 2;
    string state = 3;
}
Run Code Online (Sandbox Code Playgroud)

我想知道如何最好地使用jhump/protoreflect使用上面的消息描述符来解析文件的内容。

感谢您的帮助。

go protocol-buffers

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