Пример #1
0
        /// <summary>
        /// This method retrieves meta information and size, in bytes, of a requested storage object
        /// </summary>
        /// <example>
        /// <code>
        /// UserCredentials userCredentials = new UserCredentials("username", "api key");
        /// IConnection connection = new Connection(userCredentials);
        /// StorageItem storageItem = connection.GetStorageItemInformation("container name", "RemoteStorageItem.txt");
        /// </code>
        /// </example>
        /// <param name="containerName">The name of the container that contains the storage object</param>
        /// <param name="storageItemName">The name of the storage object</param>
        /// <returns>An instance of StorageItem containing the byte size and meta information associated with the container</returns>
        /// <exception cref="ArgumentNullException">Thrown when any of the reference parameters are null</exception>
        public StorageItemInformation GetStorageItemInformation(string containerName, string storageItemName)
        {
            if (string.IsNullOrEmpty(containerName) ||
               string.IsNullOrEmpty(storageItemName))
                throw new ArgumentNullException();

            Log.Info(this, "Getting storage item "
                + storageItemName + " information in container '"
                + containerName + "' for user");

            try
            {
                var getStorageItemInformation = new GetStorageItemInformation(StorageUrl, containerName, storageItemName);
                var getStorageItemInformationResponse = _requestfactory.Submit(getStorageItemInformation, AuthToken, _usercreds.ProxyCredentials);

                var storageItemInformation = new StorageItemInformation(storageItemName, getStorageItemInformationResponse);

                return storageItemInformation;
            }
            catch (WebException we)
            {
                Log.Error(this, "Error getting storage item "
                    + storageItemName + " information in container '"
                    + containerName + "' for user "
                    + _usercreds.Username, we);
                var response = (HttpWebResponse)we.Response;
                if (response != null && response.StatusCode == HttpStatusCode.NotFound)
                    throw new StorageItemNotFoundException("The requested storage object does not exist");

                throw;
            }
        }
Пример #2
0
        private StorageItemInformation getStorageItemInformation(string containerName, string storageItemName)
        {
            var getStorageItemInformation = new GetStorageItemInformation(StorageUrl, containerName, storageItemName);
            var getStorageItemInformationResponse = _requestfactory.Submit(getStorageItemInformation, AuthToken, _usercreds.ProxyCredentials);

            var storageItemInformation = new StorageItemInformation(getStorageItemInformationResponse.Headers);

            return storageItemInformation;
        }