架构师_程序员_码农网

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

搜索
查看: 1455|回复: 3

[资料] .NET/C# 操作对象存储US3(UFile)存储

[复制链接]
发表于 2024-8-10 21:18:27 | 显示全部楼层 |阅读模式
需求:使用 UCloud 中的对象存储服务,官方提供的 C# 版本的源码性能不太好,所以,自己根据 API 文档来实现了,速度提升了 3 倍,其它内存占用方面应该也有所提升。

对象存储US3(原名UFile)是为互联网应用提供非结构化文件云存储的服务。用户可通过浏览器、HTTP RESTful API 、SDK等多种方式实现文件的在线存取与管理。US3云存储服务按需使用,支持存储空间的无限扩展,帮助用户有效降低海量文件的存储成本;US3同时支持热点数据的高并发访问,提升终端用户访问体验。

产品介绍:https://www.ucloud.cn/site/product/ufile.html

官方 C# 版本 SDK 源码地址:https://github.com/ufilesdk-dev/ufile-csharpsdk

API 签名算法:https://docs.ucloud.cn/ufile/api/authorization

源码

调用 UFileNewAPIs 里面的静态方法即可。(略)





上一篇:【转】爱快安全ACL规则扩展案例设置教程
下一篇:.NET/C# 基于 Mutex、MemoryMappedFile 实现程序单例
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
 楼主| 发表于 2024-8-10 21:50:12 | 显示全部楼层
Mime 获取

.NET Framework:MimeMapping.GetMimeMapping(String)

参考:https://learn.microsoft.com/en-us/dotnet/api/system.web.mimemapping.getmimemapping?view=netframework-4.8.1

.NET Core:new FileExtensionContentTypeProvider().TryGetContentType(FileName, out var contentType);

参考:https://source.dot.net/#Microsoft.AspNetCore.StaticFiles/FileExtensionContentTypeProvider.cs

码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
 楼主| 发表于 2024-8-27 14:21:37 | 显示全部楼层
GetFilePath 有个BUG,修改如下:

码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
 楼主| 发表于 2024-12-18 10:33:29 | 显示全部楼层
#region 程序集 System.Net.Mail, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
// C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.11\ref\net8.0\System.Net.Mail.dll
#endregion

#nullable enable

namespace System.Net.Mime;

//
// 摘要:
//     Specifies the media type information for an email message attachment.
public static class MediaTypeNames
{
    //
    // 摘要:
    //     Specifies the kind of application data in an email message attachment.
    public static class Application
    {
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is in URL
        //     encoded format.
        public const string FormUrlEncoded = "application/x-www-form-urlencoded";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is in JSON
        //     format.
        public const string Json = "application/json";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is in JSON
        //     patch format.
        public const string JsonPatch = "application/json-patch+json";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is in JSON
        //     text sequence format.
        public const string JsonSequence = "application/json-seq";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is in Web
        //     Application Manifest.
        public const string Manifest = "application/manifest+json";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is not interpreted.
        public const string Octet = "application/octet-stream";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is in Portable
        //     Document Format (PDF).
        public const string Pdf = "application/pdf";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is in JSON
        //     problem detail format.
        public const string ProblemJson = "application/problem+json";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is in XML
        //     problem detail format.
        public const string ProblemXml = "application/problem+xml";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is in Rich
        //     Text Format (RTF).
        public const string Rtf = "application/rtf";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is a SOAP
        //     document.
        public const string Soap = "application/soap+xml";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is in WASM
        //     format.
        public const string Wasm = "application/wasm";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is in XML
        //     format.
        public const string Xml = "application/xml";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is in XML
        //     Document Type Definition format.
        public const string XmlDtd = "application/xml-dtd";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is in XML
        //     patch format.
        public const string XmlPatch = "application/xml-patch+xml";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Application data is compressed.
        public const string Zip = "application/zip";
    }
    //
    // 摘要:
    //     Specifies the kind of font data in an email message attachment.
    public static class Font
    {
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Font data is in font type collection
        //     format.
        public const string Collection = "font/collection";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Font data is in OpenType Layout
        //     (OTF) format.
        public const string Otf = "font/otf";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Font data is in SFNT format.
        public const string Sfnt = "font/sfnt";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Font data is in TrueType font
        //     (TTF) format.
        public const string Ttf = "font/ttf";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Font data is in WOFF format.
        public const string Woff = "font/woff";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Font data is in WOFF2 format.
        public const string Woff2 = "font/woff2";
    }
    //
    // 摘要:
    //     Specifies the type of image data in an email message attachment.
    public static class Image
    {
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Image data is in AVIF format.
        public const string Avif = "image/avif";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Image data is in BMP format.
        public const string Bmp = "image/bmp";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Image data is in Graphics Interchange
        //     Format (GIF).
        public const string Gif = "image/gif";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Image data is in ICO format.
        public const string Icon = "image/x-icon";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Image data is in Joint Photographic
        //     Experts Group (JPEG) format.
        public const string Jpeg = "image/jpeg";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Image data is in PNG format.
        public const string Png = "image/png";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Image data is in SVG format.
        public const string Svg = "image/svg+xml";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Image data is in Tagged Image
        //     File Format (TIFF).
        public const string Tiff = "image/tiff";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Image data is in WEBP format.
        public const string Webp = "image/webp";
    }
    //
    // 摘要:
    //     Specifies the kind of multipart data in an email message attachment.
    public static class Multipart
    {
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Multipart data consists of
        //     multiple byte ranges.
        public const string ByteRanges = "multipart/byteranges";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Multipart data is in format.
        public const string FormData = "multipart/form-data";
    }
    //
    // 摘要:
    //     Specifies the type of text data in an email message attachment.
    public static class Text
    {
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Text data is in CSS format.
        public const string Css = "text/css";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Text data is in CSV format.
        public const string Csv = "text/csv";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Text data is in HTML format.
        public const string Html = "text/html";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Text data is in Javascript
        //     format.
        public const string JavaScript = "text/javascript";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Text data is in Markdown format.
        public const string Markdown = "text/markdown";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Text data is in plain text
        //     format.
        public const string Plain = "text/plain";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Text data is in Rich Text Format
        //     (RTF).
        public const string RichText = "text/richtext";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Text data is in Rich Text Format
        //     (RTF).
        public const string Rtf = "text/rtf";
        //
        // 摘要:
        //     Specifies that the System.Net.Mime.MediaTypeNames.Text data is in XML format.
        public const string Xml = "text/xml";
    }
}
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

免责声明:
码农网所发布的一切软件、编程资料或者文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:help@itsvse.com

QQ|手机版|小黑屋|架构师 ( 鲁ICP备14021824号-2 )|网站地图

GMT+8, 2025-1-17 03:20

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表