public string GetUrlByFormatSizeQuality(IStorageInfo storageInfo, MediaElementUrlType urlType, string filePath, string fileName, string format, int maxWidthHeight, int percentage) { string sizeQualityString = BuildFormatSizeAndPercentage(format, maxWidthHeight, percentage); return(GetUrlCustom(storageInfo, urlType, filePath, fileName, sizeQualityString)); //if (mode == StorageMode.External) //{ // return $"{downloadHost}?{sizeQualityString}"; //} //else //{ // CloudBlobContainer container = GetContainer(storageId, storageAccessKey, mode, filePath); // if (string.IsNullOrEmpty(filePath)) // { // filePath = DEFAULT_CONTAINER; // } // // write a blob to the container // CloudBlockBlob blob = container.GetBlockBlobReference( // Path.Combine(filePath, fileName)); // var temp = blob.ExistsAsync(); // temp.Wait(); // if (temp.Result == false) // return string.Empty; // Uri uri = blob.StorageUri.PrimaryUri; // Uri result = new Uri(uri.AbsoluteUri + "?" + sizeQualityString); // return result.AbsoluteUri; //} }
public string GetUrlByStyle(IStorageInfo storageInfo, MediaElementUrlType urlType, string filePath, string fileName, string styleName) {//Azure不支持Style return(GetUrlCustom(storageInfo, urlType, filePath, fileName, styleName)); //if (mode == StorageMode.External) //{ // return $"{downloadHost}?{styleName}"; //} //else //{ // CloudBlobContainer container = GetContainer(storageId, storageAccessKey, mode, filePath); // if (string.IsNullOrEmpty(filePath)) // { // filePath = DEFAULT_CONTAINER; // } // // write a blob to the container // CloudBlockBlob blob = container.GetBlockBlobReference( // Path.Combine(filePath, fileName)); // var temp = blob.ExistsAsync(); // temp.Wait(); // if (temp.Result == false) // return string.Empty; // Uri uri = blob.StorageUri.PrimaryUri; // Uri result = new Uri(uri.AbsoluteUri + "?" + styleName); // return result.AbsoluteUri; //} }
public StreamReader LoadEntry ( IStorageInfo info ) { FileInfo fio = new FileInfo(info.Key); if (fio.Exists) { return fio.OpenText(); } return null; }
public FileStream LoadContent ( IStorageInfo info ) { FileInfo fio = new FileInfo(info.Key); if (fio.Exists) { return fio.OpenRead(); } return null; }
public void DeleteContent(IStorageInfo info) { FileInfo fio = new FileInfo(info.Key); if (fio.Exists) { fio.Delete(); } }
public string GetUrlCustom(IStorageInfo storageInfo, MediaElementUrlType urlType, string filePath, string fileName, string customStyleProcessStr) { if (!string.IsNullOrEmpty(filePath)) { filePath = filePath.Trim('/'); } fileName = fileName.Trim('/'); if (!string.IsNullOrEmpty(customStyleProcessStr)) { customStyleProcessStr = "?" + customStyleProcessStr; } if (urlType == MediaElementUrlType.PublishDownloadUrl || urlType == MediaElementUrlType.PublishOutputUrl) { filePath = (!string.IsNullOrEmpty(filePath) ? filePath + "/" : "") + fileName + customStyleProcessStr; var downloadHost = storageInfo.StorageHost.Trim('/'); return($"{downloadHost}/{EXTERNAL_CONTAINER}/{filePath}"); } else { CloudBlobContainer container = GetContainer(storageInfo.StorageId, storageInfo.StorageAccessKey, StorageMode.Internal, filePath); filePath = (!string.IsNullOrEmpty(filePath) ? filePath + "/" : "") + fileName;// + customStyleProcessStr; // write a blob to the container CloudBlockBlob blob = container.GetBlockBlobReference(filePath); var temp = blob.ExistsAsync(); temp.Wait(); if (temp.Result == false) { return(string.Empty); } Uri uri = blob.StorageUri.PrimaryUri; if (!string.IsNullOrEmpty(customStyleProcessStr)) { uri = new Uri(blob.StorageUri.PrimaryUri.AbsoluteUri + customStyleProcessStr); } var sasConstraints = new SharedAccessBlobPolicy(); sasConstraints.SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-5); sasConstraints.SharedAccessExpiryTime = DateTime.UtcNow.AddMinutes(60); sasConstraints.Permissions = SharedAccessBlobPermissions.Read; SharedAccessBlobHeaders sasHeaders = new SharedAccessBlobHeaders(); sasHeaders.ContentType = this.GetContentType(fileName, customStyleProcessStr, sasHeaders.ContentType); var sasBlobToken = blob.GetSharedAccessSignature(sasConstraints, sasHeaders); if (uri.AbsoluteUri.LastIndexOf('?') > 0) { return($"{uri.AbsoluteUri}&{sasBlobToken.Trim('?')}"); } return(uri.AbsoluteUri + sasBlobToken); } }
public string GetUrlCustom(IStorageInfo storageInfo, MediaElementUrlType urlType, string filePath, string fileName, string customStyleProcessStr) { if (string.IsNullOrEmpty(filePath)) { filePath = DEFAULT_CONTAINER; } filePath = filePath.Trim('/'); fileName = fileName.Trim('/'); if (urlType == MediaElementUrlType.PublishOutputUrl || urlType == MediaElementUrlType.PublishDownloadUrl) { var downloadHost = storageInfo.StorageHost.Trim('/'); if (!string.IsNullOrEmpty(customStyleProcessStr)) { customStyleProcessStr = "?x-oss-process=" + customStyleProcessStr; } return($"{downloadHost}/{filePath}/{fileName}{customStyleProcessStr}"); } else { string bucketName, objectName; OssClient client; GetClient(storageInfo.StorageId, storageInfo.StorageAccessKey, storageInfo.NetType, filePath, fileName, out bucketName, out objectName, out client); //string objectKey = //($"{filePath}/{fileName}"); // ($"{filePath}/{fileName}?{customStyleProcessStr}"); //.Trim(new char[] { '/' }); GeneratePresignedUriRequest request = new GeneratePresignedUriRequest(bucketName, objectName); request.Process = customStyleProcessStr; request.Expiration = DateTime.Now.AddHours(1); request.Method = SignHttpMethod.Get; var presignedUri = client.GeneratePresignedUri(request); return(presignedUri.AbsoluteUri); } }
public string GetUrlByFormatSizeQuality(IStorageInfo storageInfo, MediaElementUrlType urlType, string filePath, string fileName, string format, int maxWidthHeight, int percentage) { return(GetUrlCustom(storageInfo, urlType, filePath, fileName, "")); }
public StorageVersionProvider(IStorageInfo storageInfo) { _dbPlatform = storageInfo; name = _dbPlatform.GetType().Assembly.GetName().Name; }
public DataStorageVersionInfo( IStorageInfo dbPlatform) { _dbPlatform = dbPlatform; name = _dbPlatform.GetType().Assembly.GetName().Name; }
public bool Exists(IStorageInfo info) { FileInfo fio = new FileInfo(info.Key); return fio.Exists; }
public StorageInstance(IStorageInfo storageInfo) { StorageInfo = storageInfo; }
public FileStream GetContent(IStorageInfo info) { return this.Store.MediaStorage.LoadContent(info); }
public ITisAttachmentInfo[] QueryAttachmentsInfo(string attachmentNameFilter, string attachmentTypeFilter) { string sNameFilterToUse = "*"; string typeFilterToUse = "*"; if (StringUtil.IsStringInitialized(attachmentNameFilter)) { sNameFilterToUse = attachmentNameFilter; } if (StringUtil.IsStringInitialized(attachmentTypeFilter)) { typeFilterToUse = attachmentTypeFilter; } // Create filter string filter = String.Format( "{0}.{1}", sNameFilterToUse, typeFilterToUse); // Perform query List <StorageInfo> storagesInfo = new List <StorageInfo>( m_SourceStorage.QueryStorageInfo(String.Empty, filter, StorageInfoFlags.Size | StorageInfoFlags.LastModified)); string[] subDirs = m_SourceStorage.QuerySubDirs(String.Empty, true); foreach (var subdir in subDirs) { StorageInfo[] subDirsStoragesInfo = m_SourceStorage.QueryStorageInfo(subdir, filter, StorageInfoFlags.Size | StorageInfoFlags.LastModified); foreach (StorageInfo storageInfo in subDirsStoragesInfo) { storagesInfo.Add(new StorageInfo( Path.Combine(subdir, storageInfo.Name), storageInfo.SizeBytes, storageInfo.CRC32, storageInfo.LastModified, storageInfo.DataFlags)); } } ITisAttachmentInfo[] attachmentInfoArray = new ITisAttachmentInfo[storagesInfo.Count]; // Repack IBLOBInfo to ITisAttachmentInfo for (int i = 0; i < storagesInfo.Count; i++) { IStorageInfo storageInfo = storagesInfo[i]; attachmentInfoArray[i] = new AttachmentInfo( storageInfo.Name, AttachmentsUtil.GetAttachmentType(storageInfo.Name), storageInfo.SizeBytes, storageInfo.LastModified, storageInfo.CRC32); } return(attachmentInfoArray); }
public string GetUrlByStyle(IStorageInfo storageInfo, MediaElementUrlType urlType, string filePath, string fileName, string styleName) { return(""); }
public string GetUrlByStyle(IStorageInfo storageInfo, MediaElementUrlType urlType, string filePath, string fileName, string styleName) { return(GetUrlCustom(storageInfo, urlType, filePath, fileName, string.IsNullOrEmpty(styleName) ? "" : $"style/{styleName}")); }
/* * public string GetUrlByFormatSizeQuality(string storageId, string storageAccessKey, * MediaElementUrlType urlType, string downloadHost, string filePath, string fileName, * string format, int maxWidthHeight, int percentage) * { * string sizeQualityString = BuildFormatSizeAndPercentage(format, maxWidthHeight, percentage); * * return GetUrlCustom(storageId, storageAccessKey, urlType, * downloadHost, filePath, fileName, sizeQualityString); * } * * public string GetUrlByStyle(string storageId, string storageAccessKey, MediaElementUrlType urlType, * string downloadHost, string filePath, string fileName, string styleName) * { * return GetUrlCustom(storageId, storageAccessKey, urlType, * downloadHost, filePath, fileName, * string.IsNullOrEmpty(styleName) ? "" : $"x-oss-process=style/{styleName}"); * } * * public string GetUrlCustom(string storageId, string storageAccessKey, MediaElementUrlType urlType, * string downloadHost, string filePath, string fileName, string customStyleProcessStr) * { * if (string.IsNullOrEmpty(filePath)) * { * filePath = DEFAULT_CONTAINER; * } * filePath = filePath.Trim('/'); * fileName = fileName.Trim('/'); * * if (urlType == MediaElementUrlType.PublishOutputUrl || urlType == MediaElementUrlType.PublishDownloadUrl) || { || downloadHost = downloadHost.Trim('/'); || if (!string.IsNullOrEmpty(customStyleProcessStr)) || { || customStyleProcessStr = "?" + customStyleProcessStr; || } || return $"{downloadHost}/{filePath}/{fileName}{customStyleProcessStr}"; || } || else || { || StorageMode mode = StorageMode.Internal; || if (urlType == MediaElementUrlType.OutputUrl) || mode = StorageMode.External; || string bucketName, objectName; || OssClient client; || GetClient(mode, storageId, storageAccessKey, filePath, fileName, || out bucketName, out objectName, out client); || || string objectKey = //($"{filePath}/{fileName}"); || ($"{filePath}/{fileName}?{customStyleProcessStr}"); || //.Trim(new char[] { '/' }); || || var presignedUri = client.GeneratePresignedUri(bucketName, objectKey, || DateTime.Now.AddHours(1), SignHttpMethod.Get); || || return presignedUri.AbsoluteUri; || } ||}*/ public string GetUrlByFormatSizeQuality(IStorageInfo storageInfo, MediaElementUrlType urlType, string filePath, string fileName, string format, int maxWidthHeight, int percentage) { string sizeQualityString = BuildFormatSizeAndPercentage(format, maxWidthHeight, percentage); return(GetUrlCustom(storageInfo, urlType, filePath, fileName, sizeQualityString)); }
public string GetUrlCustom(IStorageInfo storageInfo, MediaElementUrlType urlType, string filePath, string fileName, string customStyleProcessStr) { return(storageInfo.StorageHost + "/" + storageInfo.StorageAccessKey + "/" + filePath + "/" + fileName); }
public void SaveEntry(IStorageInfo info, string entry) { StreamWriter sw = File.CreateText(info.Key); sw.Write(entry); sw.Close(); }
public StreamReader GetMetadata(IStorageInfo info) { return this.Store.MemberStorage.LoadEntry(info); }
public void SaveContent(IStorageInfo info, Byte[] content) { FileStream fs = File.Create(info.Key); fs.Write(content, 0, content.Length); fs.Close(); }
public IMember LoadMember(string memberId, IStorageInfo info) { string entry = this.GetMetadata(info).ReadToEnd(); XmlDocument doc = new XmlDocument(); doc.LoadXml(entry); return Member.FromEntry(this, doc); }
public string GetUrlCustom(IStorageInfo storageInfo, MediaElementUrlType urlType, string filePath, string fileName, string customStyleProcessStr) { return(string.Empty); }