我有安全的端点。我需要在来自 Angular 的 Http Get 请求的头部传递 jwt 令牌以流式传输视频。
dotnet 核心控制器中的端点如下所示(简化):
[Route("api/GetVideo/{videoId}")]
public async Task<IActionResult> GetVideoAsync(int videoId)
{
string videoFilePath = GiveMeTheVideoFilePath(videoId);
return this.PhysicalFile(videoFilePath, "application/octet-stream", enableRangeProcessing: true);
}
Run Code Online (Sandbox Code Playgroud)
角度代码: video.component.html
<video width="100%" height="320" crossorigin="anonymous" controls #videoElement>
<source
[src]="'http://mydomain/api/GetVideo/1' | authVideo | async" type="application/octet-stream"
/>
</video>
Run Code Online (Sandbox Code Playgroud)
video.pipe.ts
@Pipe({
name: 'authVideo',
})
export class AuthVideoPipe implements PipeTransform {
constructor(private http: HttpClient, private auth: AuthTokenService) {}
transform(url: string) {
return new Observable<string>(observer => {
const token = this.auth.getToken(); //this line gets the jwt token …Run Code Online (Sandbox Code Playgroud) 我想检查布尔值是否为真,然后在WHERE子句中决定使用什么条件.
假设布尔变量是@checkbool:
SELECT *
FROM TableA A
WHERE
--if @checkbool is true, run this
A.Id = 123
--if @checkbool is false, run this
A.Id <> 123
Run Code Online (Sandbox Code Playgroud)
有没有办法否定一个条件?就像在C++中一样,你可以做到!(条件).
如果没有,解决这个问题的最佳方法是什么?
谢谢!