public void SetUp()
 {
     container = new Container(Constants.REMOTE_CONTAINER_NAME);
 }
Ejemplo n.º 2
0
        private string GetContainerCdnUri(Container container)
        {
            if (!HasCDN())
                return null;

            try
            {
                var publicContainer = GetPublicContainerInformation(container.Name);
                return publicContainer == null ? "" : publicContainer.CdnUri;
            }
            catch (ContainerNotFoundException)
            {
                return "";
            }
            catch (WebException we)
            {
                Log.Error(this, "Error getting container CDN Uril from getContainerInformation for container '"
                                + container.Name + "' for user "
                                + _usercreds.Username, we);

                var response = (HttpWebResponse)we.Response;
                if (response != null && response.StatusCode == HttpStatusCode.Unauthorized)
                {
                    _reInitAuthSequence();
                    throw new AuthenticationFailedException(we.Message);
                }

                throw;
            }
        }
Ejemplo n.º 3
0
        private Container getContainerInformation(string containerName)
        {
            var getContainerInformation = new GetContainerInformation(StorageUrl, containerName);
            var getContainerInformationResponse = _requestfactory.Submit(getContainerInformation, AuthToken, _usercreds.ProxyCredentials);
            var container = new Container(containerName)
            {
                ByteCount =
                    long.Parse(
                    getContainerInformationResponse.Headers[Constants.X_CONTAINER_BYTES_USED]),
                ObjectCount =
                    long.Parse(
                    getContainerInformationResponse.Headers[
                        Constants.X_CONTAINER_STORAGE_OBJECT_COUNT])
            };

            foreach (var key in getContainerInformationResponse.Headers.AllKeys)
            {
                if (!String.IsNullOrEmpty(key))
                {
                    if ((key.StartsWith(Constants.X_CONTAINTER_META_DATA_HEADER)) &&
                        (key.Length > Constants.X_CONTAINTER_META_DATA_HEADER.Length))
                    {
                        string value = getContainerInformationResponse.Headers[key];
                        if (!String.IsNullOrEmpty(value))
                        {
                            // if the specified key already exists, it will be overwritten
                            // also note: we strip out the "X-Container-Meta-" prefix
                            container.Metadata[key.Substring(Constants.X_CONTAINTER_META_DATA_HEADER.Length)] = value;
                        }
                    }
                }
            }

            var url = GetContainerCdnUri(container);
            if (!string.IsNullOrEmpty(url)) url += "/";
            container.CdnUri = url;
            return container;
        }
Ejemplo n.º 4
0
 private Container getContainerInformation(string containerName)
 {
     var getContainerInformation = new GetContainerInformation(StorageUrl, containerName);
     var getContainerInformationResponse = _requestfactory.Submit(getContainerInformation, AuthToken, _usercreds.ProxyCredentials);
     var container = new Container(containerName)
     {
         ByteCount =
             long.Parse(
             getContainerInformationResponse.Headers[Constants.X_CONTAINER_BYTES_USED]),
         ObjectCount =
             long.Parse(
             getContainerInformationResponse.Headers[
                 Constants.X_CONTAINER_STORAGE_OBJECT_COUNT])
     };
     var url = GetContainerCdnUri(container);
     if (!string.IsNullOrEmpty(url)) url += "/";
     container.CdnUri = url;
     return container;
 }