예제 #1
0
        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;
            //}
        }
예제 #2
0
        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;
            //}
        }
예제 #3
0
파일: FS.cs 프로젝트: xxjeng/nuxleus
        public StreamReader LoadEntry ( IStorageInfo info ) {
            FileInfo fio = new FileInfo(info.Key);
            if (fio.Exists) {
                return fio.OpenText();
            }

            return null;
        }
예제 #4
0
파일: FS.cs 프로젝트: xxjeng/nuxleus
        public FileStream LoadContent ( IStorageInfo info ) {
            FileInfo fio = new FileInfo(info.Key);
            if (fio.Exists) {
                return fio.OpenRead();
            }

            return null;
        }
예제 #5
0
파일: FS.cs 프로젝트: xxjeng/nuxleus
 public void DeleteContent(IStorageInfo info)
 {
     FileInfo fio = new FileInfo(info.Key);
     if (fio.Exists)
     {
         fio.Delete();
     }
 }
예제 #6
0
        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);
            }
        }
예제 #7
0
        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);
            }
        }
예제 #8
0
 public string GetUrlByFormatSizeQuality(IStorageInfo storageInfo, MediaElementUrlType urlType, string filePath, string fileName, string format, int maxWidthHeight, int percentage)
 {
     return(GetUrlCustom(storageInfo, urlType, filePath, fileName, ""));
 }
예제 #9
0
 public StorageVersionProvider(IStorageInfo storageInfo)
 {
     _dbPlatform = storageInfo;
     name        = _dbPlatform.GetType().Assembly.GetName().Name;
 }
예제 #10
0
 public DataStorageVersionInfo(
     IStorageInfo dbPlatform)
 {
     _dbPlatform = dbPlatform;
     name        = _dbPlatform.GetType().Assembly.GetName().Name;
 }
예제 #11
0
파일: FS.cs 프로젝트: xxjeng/nuxleus
 public bool Exists(IStorageInfo info)
 {
     FileInfo fio = new FileInfo(info.Key);
     return fio.Exists;
 }
예제 #12
0
 public StorageInstance(IStorageInfo storageInfo)
 {
     StorageInfo = storageInfo;
 }
예제 #13
0
 public FileStream GetContent(IStorageInfo info)
 {
     return this.Store.MediaStorage.LoadContent(info);
 }
예제 #14
0
        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);
        }
예제 #15
0
 public string GetUrlByStyle(IStorageInfo storageInfo, MediaElementUrlType urlType, string filePath, string fileName, string styleName)
 {
     return("");
 }
예제 #16
0
 public string GetUrlByStyle(IStorageInfo storageInfo, MediaElementUrlType urlType, string filePath, string fileName, string styleName)
 {
     return(GetUrlCustom(storageInfo, urlType, filePath, fileName, string.IsNullOrEmpty(styleName) ? "" : $"style/{styleName}"));
 }
예제 #17
0
        /*
         * 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));
        }
예제 #18
0
 public string GetUrlCustom(IStorageInfo storageInfo, MediaElementUrlType urlType, string filePath, string fileName, string customStyleProcessStr)
 {
     return(storageInfo.StorageHost + "/" + storageInfo.StorageAccessKey + "/" + filePath + "/" + fileName);
 }
예제 #19
0
파일: FS.cs 프로젝트: xxjeng/nuxleus
 public void SaveEntry(IStorageInfo info, string entry)
 {
     StreamWriter sw = File.CreateText(info.Key);
     sw.Write(entry);
     sw.Close();
 }
예제 #20
0
 public StreamReader GetMetadata(IStorageInfo info)
 {
     return this.Store.MemberStorage.LoadEntry(info);
 }
예제 #21
0
파일: FS.cs 프로젝트: xxjeng/nuxleus
 public void SaveContent(IStorageInfo info, Byte[] content)
 {
     FileStream fs = File.Create(info.Key);
     fs.Write(content, 0, content.Length);
     fs.Close();
 }
예제 #22
0
 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);
 }
예제 #23
0
 public string GetUrlCustom(IStorageInfo storageInfo, MediaElementUrlType urlType,
                            string filePath, string fileName, string customStyleProcessStr)
 {
     return(string.Empty);
 }