/// <summary>
        /// Initializes a new instance of the <see cref="PutStorageItem"/> class for putting an item with meta data.
        /// </summary>
        /// <param name="storageUrl">the customer unique url to interact with cloudfiles</param>
        /// <param name="containerName">the name of the container where the storage item is located</param>
        /// <param name="remoteStorageItemName">the name of the storage item to add meta information too</param>
        /// <param name="fileToSend">the file stream of the file to put into cloudfiles</param>
        /// <param name="metadata">dictionary of meta tags to apply to the storage item</param>
        /// <exception cref="ArgumentNullException">Thrown when any of the reference parameters are null</exception>
        /// <exception cref="ContainerNameException">Thrown when the container name is invalid</exception>
        /// <exception cref="StorageItemNameException">Thrown when the object name is invalid</exception>
        public PutStorageItem(string storageUrl, string containerName,
                              string remoteStorageItemName,
                              Stream fileToSend,
                              Dictionary <string, string> metadata)
        {
            if (string.IsNullOrEmpty(storageUrl) ||
                string.IsNullOrEmpty(containerName) ||
                fileToSend == null ||
                string.IsNullOrEmpty(remoteStorageItemName))
            {
                throw new ArgumentNullException();
            }

            if (!ContainerNameValidator.Validate(containerName))
            {
                throw new ContainerNameException();
            }
            if (!ObjectNameValidator.Validate(remoteStorageItemName))
            {
                throw new StorageItemNameException();
            }

            _fileUrl               = CleanUpFilePath(remoteStorageItemName);
            _storageUrl            = storageUrl;
            _containerName         = containerName;
            _remoteStorageItemName = remoteStorageItemName;
            _metadata              = metadata;
            _fileToSend            = fileToSend;
        }
        /// <summary>
        /// SetStorageItemMetaInformation constructor
        /// </summary>
        /// <param name="storageUrl">the customer unique url to interact with cloudfiles</param>
        /// <param name="containerName">the name of the container where the storage item is located</param>
        /// <param name="storageItemName">the name of the storage item to add meta information too</param>
        /// <param name="metadata">dictionary containing the meta tags on the storage item</param>
        /// <exception cref="System.ArgumentNullException">Thrown when any of the arguments are null</exception>
        public SetStorageItemMetaInformation(string storageUrl, string containerName, string storageItemName,
                                             Dictionary <string, string> metadata)
        {
            if (string.IsNullOrEmpty(storageUrl) ||
                string.IsNullOrEmpty(containerName) ||
                string.IsNullOrEmpty(storageItemName))
            {
                throw new ArgumentNullException();
            }


            if (!ContainerNameValidator.Validate(containerName))
            {
                throw new ContainerNameException();
            }
            if (!ObjectNameValidator.Validate(storageItemName))
            {
                throw new StorageItemNameException();
            }

            _storageUrl      = storageUrl;
            _containerName   = containerName;
            _storageItemName = storageItemName;
            this.metadata    = metadata;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PutStorageItem"/> class for putting an item with a local file.
        /// </summary>
        /// <param name="storageUrl">The customer unique url to interact with cloudfiles</param>
        /// <param name="containerName">The name of the container where the storage item is located</param>
        /// <param name="remoteStorageItemName">The name of the storage item to add meta information too</param>
        /// <param name="localFilePath">The path of the file to put into cloudfiles</param>
        /// <param name="metadata">Dictionary of meta tags to apply to the storage item</param>
        /// <exception cref="ArgumentNullException">Thrown when any of the reference parameters are null</exception>
        /// <exception cref="ContainerNameException">Thrown when the container name is invalid</exception>
        /// <exception cref="StorageItemNameException">Thrown when the object name is invalid</exception>
        public PutStorageItem(string storageUrl, string containerName, string remoteStorageItemName,
                              string localFilePath,
                              Dictionary <string, string> metadata)
        {
            _storageUrl            = storageUrl;
            _containerName         = containerName;
            _remoteStorageItemName = remoteStorageItemName;
            _metadata = metadata;

            if (string.IsNullOrEmpty(storageUrl) ||
                string.IsNullOrEmpty(containerName) ||
                string.IsNullOrEmpty(localFilePath) ||
                string.IsNullOrEmpty(remoteStorageItemName))
            {
                throw new ArgumentNullException();
            }

            if (!ContainerNameValidator.Validate(containerName))
            {
                throw new ContainerNameException();
            }

            if (!ObjectNameValidator.Validate(remoteStorageItemName))
            {
                throw new StorageItemNameException();
            }

            _fileUrl    = CleanUpFilePath(localFilePath);
            _fileToSend = new FileStream(_fileUrl, FileMode.Open, FileAccess.Read);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CopyStorageItem"/> class.
        /// </summary>
        /// <param name="url">the customer unique url to interact with cloudfiles</param>
        /// <param name="containerName">the name of the container where the storage item is located</param>
        /// <param name="storageItemName">the name of the storage item to add meta information too</param>
        /// <param name="emailAddresses">the email addresses to notify who</param>
        /// <exception cref="ArgumentNullException">Thrown when any of the reference parameters are null</exception>
        /// <exception cref="ContainerNameException">Thrown when the container name is invalid</exception>
        /// <exception cref="StorageItemNameException">Thrown when the object name is invalid</exception>
        public CopyStorageItem(string url, string containerName, string sourceItemName, string destItemName, string[] emailAddresses)
        {
            if (string.IsNullOrEmpty(url) ||
                string.IsNullOrEmpty(containerName) ||
                string.IsNullOrEmpty(sourceItemName) ||
                string.IsNullOrEmpty(destItemName))
            {
                throw new ArgumentNullException();
            }

            if (!ContainerNameValidator.Validate(containerName))
            {
                throw new ContainerNameException();
            }

            if (!ObjectNameValidator.Validate(sourceItemName))
            {
                throw new StorageItemNameException();
            }

            if (!ObjectNameValidator.Validate(destItemName))
            {
                throw new StorageItemNameException();
            }

            _url            = url;
            _containerName  = containerName;
            _sourceItemName = sourceItemName;
            _destItemName   = destItemName;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GetStorageItemInformation"/> class.
        /// </summary>
        /// <param name="storageUrl">The customer unique url to interact with cloudfiles</param>
        /// <param name="containerName">The name of the container where the storage item is located</param>
        /// <param name="storageItemName">The name of the storage item to add meta information too</param>
        /// <exception cref="ArgumentNullException">Thrown when any of the reference parameters are null</exception>
        /// <exception cref="ContainerNameException">Thrown when the container name is invalid</exception>
        /// <exception cref="StorageItemNameException">Thrown when the object name is invalid</exception>
        public GetStorageItemInformation(string storageUrl, string containerName, string storageItemName)
        {
            if (string.IsNullOrEmpty(storageUrl) ||
                string.IsNullOrEmpty(containerName) ||
                string.IsNullOrEmpty(storageItemName))
            {
                throw new ArgumentNullException();
            }

            if (!ContainerNameValidator.Validate(containerName))
            {
                throw new ContainerNameException();
            }
            if (!ObjectNameValidator.Validate(storageItemName))
            {
                throw new StorageItemNameException();
            }

            _storageUrl      = storageUrl;
            _containerName   = containerName;
            _storageItemName = storageItemName;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// GetStorageItem constructor with http comparison header fields
        /// </summary>
        /// <param name="storageUrl">the customer unique url to interact with cloudfiles</param>
        /// <param name="containerName">the name of the container where the storage item is located</param>
        /// <param name="storageItemName">the name of the storage item to add meta information too</param>
        /// <param name="requestHeaderFields">dictionary of request header fields to apply to the request</param>
        /// <exception cref="ContainerNameException">Thrown when the container name is invalid</exception>
        /// <exception cref="StorageItemNameException">Thrown when the object name is invalid</exception>
        public GetStorageItem(string storageUrl, string containerName, string storageItemName,
                              Dictionary <RequestHeaderFields, string> requestHeaderFields)
        {
            _storageUrl          = storageUrl;
            _containerName       = containerName;
            _storageItemName     = storageItemName;
            _requestHeaderFields = requestHeaderFields;
            if (string.IsNullOrEmpty(storageUrl) ||
                string.IsNullOrEmpty(containerName) ||
                string.IsNullOrEmpty(storageItemName))
            {
                throw new ArgumentNullException();
            }

            if (!ContainerNameValidator.Validate(containerName))
            {
                throw new ContainerNameException();
            }
            if (!ObjectNameValidator.Validate(storageItemName))
            {
                throw new StorageItemNameException();
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DeleteStorageItem"/> class.
        /// </summary>
        /// <param name="url">the customer unique url to interact with cloudfiles</param>
        /// <param name="containerName">the name of the container where the storage item is located</param>
        /// <param name="storageItemName">the name of the storage item to add meta information too</param>
        /// <param name="emailAddresses">the email addresses to notify who</param>
        /// <exception cref="ArgumentNullException">Thrown when any of the reference parameters are null</exception>
        /// <exception cref="ContainerNameException">Thrown when the container name is invalid</exception>
        /// <exception cref="StorageItemNameException">Thrown when the object name is invalid</exception>
        public DeleteStorageItem(string url, string containerName, string storageItemName, string[] emailAddresses)
        {
            if (string.IsNullOrEmpty(url) ||
                string.IsNullOrEmpty(containerName) ||
                string.IsNullOrEmpty(storageItemName))
            {
                throw new ArgumentNullException();
            }

            if (!ContainerNameValidator.Validate(containerName))
            {
                throw new ContainerNameException();
            }

            if (!ObjectNameValidator.Validate(storageItemName))
            {
                throw new StorageItemNameException();
            }

            _url             = url;
            _containerName   = containerName;
            _storageItemName = storageItemName;
            _emailAddresses  = emailAddresses;
        }
Ejemplo n.º 8
0
        public void should_be_valid()
        {
            var objectName = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz!@#$%^&*()-+={}[]|\'\":;,.<>~`/";

            Assert.That(ObjectNameValidator.Validate(objectName), Is.True);
        }
Ejemplo n.º 9
0
        public void should_be_invalid()
        {
            var objectName = new string('a', ObjectNameValidator.MAX_OBJECT_NAME_LENGTH + 1);

            Assert.That(ObjectNameValidator.Validate(objectName), Is.False);
        }
Ejemplo n.º 10
0
        public void should_be_invalid()
        {
            var objectName = "objectName?withQuestionMark";

            Assert.That(ObjectNameValidator.Validate(objectName), Is.False);
        }