JJ Chen

.NET Dev & Azure Opsᵇᵉᵗᵃ

All Posts

Analyze linux disk space

参考连接: CSDN:浅谈linux中/dev/vda1文件满了解决方法 今天上服务器,发现磁盘增长有点多,用 df -h 看到 /dev/vda1 占了 30G。 file 可以看到,挂载的是根目录 /,导航进去,参看各个文件夹的大小 cd / du -sh * 根据 du -sh * 输出的结果,一层一层找到大文件,依次清理即可。  …
Linux

aliyun oss download with custom filename

阿里云对象存储产品文档:通过设置HTTP头管理OSS文件元数据 阿里云 OSS 生成对象的下载 URL 时,浏览器会使用保存到 OSS 的文件名作为下载文件名。 但一般业务,在保存时,会生成一个“唯一”的文件名,比如用 GUID 生成——这就导致 下载文件名 与 实际文件名 不一致的问题。 为了解决这个问题,可以在上传文件时,通过设置 Content-Disposition 来解决。 public string? PutObject(string fileName, string key, Stream content) { var client = GetClient(); var _ = client.PutObject(AppSettings.OSSBucketName, key, content, new ObjectMetadata() { …
OSS

aliyun oss update object meta issue

阿里 OSS SDK 里更新元数据的方法有问题,会报字典同 key 异常,移除 Date 字段后可正常更新。 public void UpdateMeta(string fileName, string key) { OssClient client = GetClient(); var metadata = client.GetObjectMetadata(AppSettings.OSSBucketName, key); metadata.ContentDisposition = $attachment;filename*=utf-8''{HttpUtils.EncodeUri(fileName, utf-8)}; metadata.HttpMetadata.Remove(Date); client.ModifyObjectMeta( …
OSS

SignalR issue in AutoWrapper

Github: AutoWrapper 同时使用 AutoWrapper 和 SignalR 的时候,要记得把 SignalR 的路由配置到除外名单,否则 SignalR 客户端会一直连不上。 // SignalR 配置 builder.Services.AddSignalR(); app.UseRouting(); app.MapHubChatHub(/chatHub); // Auto Wrapper 配置 app.UseApiResponseAndExceptionWrapper(new AutoWrapperOptions { ExcludePaths = [ new AutoWrapperExcludePath(/chatHub/.*|/chatHub, ExcludeMode.Regex) ] });  …
SignalR AutoWrapper

SignalR minimal demo

微软教程:ASP.NET Core SignalR 入门 项目结构 项目结构 运行效果 运行效果 前端 !DOCTYPE html html lang=en head meta charset=UTF-8 meta name=viewport content=width=device-width, initial-scale=1.0 titleSignalR Demo/title script src=https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js/script script src=https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/5.0.8/signalr.min.js/script /head …
SignalR

Google 地图瓦片国内域名失效

今天用一个第三方的系统看地图,发现谷歌地图的卫星图挂了。 F12 查了下,一堆接口 404——发现瓦片是通过 gac-geo.googlecnapps.cn 获取的,比如: https://gac-geo.googlecnapps.cn/maps/vt?lyrs=shl=zh-CNx=223346y=103684z=18 (这域名还是谷歌自己注册😏) 试了下直接把域名换成 www.google.com,可以拿到瓦片(请求超时的,请使用魔法),比如: https://www.google.com/maps/vt?lyrs=shl=zh-CNx=223346y=103684z=18 因为是第三方的系统,改不了人家的代码,只能直接想办法重定向了。 找了个浏览器插件 Redirector,直接搜就有: Redirector-add-on 添加一个重定向: Example URL:直接用上面的。  …

EF Core 字段备注

参考:博客园:小技巧 EntityFrameworkCore 实现 CodeFirst 通过模型生成数据库表时自动携带模型及字段注释信息  …

基于 APISIX 的微入侵登录方案

参考:博客园:apisix基于username和password的JWT验证插件 实现 Lua 脚本 -- Licensed to the Apache Software Foundation (ASF) under one or more -- contributor license agreements. See the NOTICE file distributed with -- this work for additional information regarding copyright ownership. -- The ASF licenses this file to You under the Apache License, Version 2.0 -- (the License); you may not use this file except in  …
APISIX Solution