/*********************************************************************** * Project: CoreCms * ProjectName: 核心内容管理系统 * Web: https://www.corecms.net * Author: 大灰灰 * Email: jianweie@163.com * CreateTime: 2021/8/16 12:44:16 * Description: 暂无 ***********************************************************************/ using CoreCms.Net.Configuration; namespace CoreCms.Net.Utility.Helper { /// /// 上传帮助类 /// public static class UpLoadHelper { /// /// 上传路径格式化操作,防止不同类型下上传路径写入失败问题。 /// /// 上传类型 /// 原始路径 /// 地址 /// public static string PathFormat(string storageType, string oldFilePath, string bucketBindUrl) { string newPath; //switch (storageType) //{ // case "LocalStorage": // newPath = oldFilePath.StartsWith("/") ? oldFilePath : "/" + oldFilePath; // break; // case "AliYunOSS": // newPath = oldFilePath.StartsWith("/") ? oldFilePath.Substring(1) : oldFilePath; // break; // case "QCloudOSS": // newPath = oldFilePath.StartsWith("/") ? oldFilePath.Substring(1) : oldFilePath; // break; // default: // newPath = "/upload/"; // break; //} if (bucketBindUrl.EndsWith("/")) { newPath = oldFilePath.StartsWith("/") ? oldFilePath[1..] : oldFilePath; } else { newPath = oldFilePath.StartsWith("/") ? oldFilePath : "/" + oldFilePath; } newPath = newPath.EndsWith("/") ? newPath : newPath + "/"; return newPath; } } }