Пример #1
0
        /// <summary>
        /// Get files from azure blob storage
        /// </summary>
        /// <param name="container">Azure storage Blob container name</param>
        /// <param name="blobName">blob file name</param>
        /// <param name="downloadDataType">Download return data</param>
        /// <returns>Blob information in a specific format</returns>
        public T GetBlobInformation <T>(string container, string blobName, DownloadDataType downloadDataType)
        {
            try
            {
                var blobContainer = BlobReference(container);

                if (!blobContainer.Exists())
                {
                    throw new Exception("Blob Container does not exist.");
                }

                var blob = blobContainer.GetBlockBlobReference(blobName);

                if (!blob.Exists())
                {
                    throw new Exception("Blob does not exist.");
                }

                return((T)GetData(blob, downloadDataType));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #2
0
        private object GetData(CloudBlockBlob blob, DownloadDataType downloadDataType)
        {
            switch (downloadDataType)
            {
            case DownloadDataType.Text:
                return(blob.DownloadText());

            case DownloadDataType.ByteArray:
                var document = new byte[blob.Properties.Length];

                blob.DownloadToByteArray(document, 0);

                return(document);

            default:
                throw new ArgumentOutOfRangeException("downloadDataType");
            }
        }
Пример #3
0
 /// <summary>
 /// 通信優先度を取得する
 /// </summary>
 /// <returns><c>static void</c></returns>
 public static int GetNetPriority(this DownloadDataType type)
 {
     return(NET_PRIORITY_LIST[(int)type]);
 }
Пример #4
0
        /// <summary>
        /// Get files from azure file storage
        /// </summary>
        /// <param name="fileService">Unit name or File service</param>
        /// <param name="directory">File share folder (string.empty if not has folder)</param>
        /// <param name="fileName">File names with extension (i.e. file_name.extension)</param>
        /// <param name="downloadDataType">Download return data</param>
        /// <returns>File information in a specific format</returns>
        public T GetFileInformation <T>(string fileService, string directory, string fileName, DownloadDataType downloadDataType)
        {
            try
            {
                var context = FileReference(fileService);

                if (!context.Exists())
                {
                    throw new Exception("Error trying to retreive file data.");
                }

                var dir = GetDirectory(context, directory);

                if (!dir.Exists())
                {
                    throw new Exception("Directory entry does not exist");
                }

                var file = dir.GetFileReference(fileName);

                if (!file.Exists())
                {
                    throw new Exception("File searched does not exist");
                }

                return((T)GetData(file, downloadDataType));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }