Esempio n. 1
0
        public StandaloneAzureBlockBlob(string containerDirectory, string blobName)
        {
            StringValidation.NotNullOrWhitespace(containerDirectory, "containerDirectory");
            StringValidation.NotNullOrWhitespace(blobName, "blobName");

            _blobName     = blobName;
            _blobPath     = Path.Combine(containerDirectory, blobName);
            _metadataPath = Path.Combine(containerDirectory, ".meta", blobName);

            var blobDirectory = Path.GetDirectoryName(_blobPath);

            if (blobDirectory == null)
            {
                throw new InvalidOperationException("Could not determine the blob directory");
            }
            if (blobDirectory != containerDirectory)
            {
                if (!Directory.Exists(blobDirectory))
                {
                    _blobDirectory = blobDirectory;
                }
                var metadataDirectory = Path.GetDirectoryName(_metadataPath);
                if (metadataDirectory != null && !Directory.Exists(metadataDirectory))
                {
                    _metadataDirectory = metadataDirectory;
                }
            }

            _metadata   = new Dictionary <string, string>();
            _properties = new StandaloneAzureBlobProperties {
                Length = -1, ContentType = null
            };
        }
        public StandaloneAzureBlockBlob(string containerDirectory, string blobName)
        {
            StringValidation.NotNullOrWhitespace(containerDirectory, "containerDirectory");
            StringValidation.NotNullOrWhitespace(blobName, "blobName");

            _blobName = blobName;
            _blobPath = Path.Combine(containerDirectory, blobName);
            _metadataPath = Path.Combine(containerDirectory, ".meta", blobName);

            var blobDirectory = Path.GetDirectoryName(_blobPath);
            if (blobDirectory == null)
            {
                throw new InvalidOperationException("Could not determine the blob directory");
            }
            if (blobDirectory != containerDirectory)
            {
                if (!Directory.Exists(blobDirectory))
                {
                    _blobDirectory = blobDirectory;
                }
                var metadataDirectory = Path.GetDirectoryName(_metadataPath);
                if (metadataDirectory != null && !Directory.Exists(metadataDirectory))
                {
                    _metadataDirectory = metadataDirectory;
                }
            }

            _metadata = new Dictionary<string, string>();
            _properties = new StandaloneAzureBlobProperties { Length = -1, ContentType = null };
        }