Beispiel #1
0
        /// <summary>
        /// Generates a web request to return a listing of all files and subdirectories in the directory.
        /// </summary>
        /// <param name="uri">The absolute URI to the share.</param>
        /// <param name="timeout">The server timeout interval.</param>
        /// <param name="shareSnapshot">A <see cref="DateTimeOffset"/> specifying the share snapshot timestamp, if the share is a snapshot.</param>
        /// <param name="listingContext">A set of parameters for the listing operation.</param>
        /// <returns>A web request to use to perform the operation.</returns>
        public static StorageRequestMessage List(Uri uri, int?timeout, DateTimeOffset?shareSnapshot, FileListingContext listingContext, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials)
        {
            UriQueryBuilder directoryBuilder = GetDirectoryUriQueryBuilder();

            DirectoryHttpRequestMessageFactory.AddShareSnapshot(directoryBuilder, shareSnapshot);
            directoryBuilder.Add(Constants.QueryConstants.Component, "list");

            if (listingContext != null)
            {
                if (listingContext.Marker != null)
                {
                    directoryBuilder.Add("marker", listingContext.Marker);
                }

                if (listingContext.MaxResults.HasValue)
                {
                    directoryBuilder.Add("maxresults", listingContext.MaxResults.ToString());
                }

                if (listingContext.Prefix != null)
                {
                    directoryBuilder.Add("prefix", listingContext.Prefix);
                }
            }

            StorageRequestMessage request = HttpRequestMessageFactory.CreateRequestMessage(HttpMethod.Get, uri, timeout, directoryBuilder, content, operationContext, canonicalizer, credentials);

            return(request);
        }
Beispiel #2
0
        /// <summary>
        /// Generates a web request to return the user-defined metadata for this directory.
        /// </summary>
        /// <param name="uri">The absolute URI to the directory.</param>
        /// <param name="timeout">The server timeout interval.</param>
        /// <param name="shareSnapshot">A <see cref="DateTimeOffset"/> specifying the share snapshot timestamp, if the share is a snapshot.</param>
        /// <param name="accessCondition">The access condition to apply to the request.</param>
        /// <returns>A web request to use to perform the operation.</returns>
        public static StorageRequestMessage GetMetadata(Uri uri, int?timeout, DateTimeOffset?shareSnapshot, AccessCondition accessCondition, HttpContent content, OperationContext operationContext, ICanonicalizer canonicalizer, StorageCredentials credentials)
        {
            UriQueryBuilder directoryBuilder = GetDirectoryUriQueryBuilder();

            DirectoryHttpRequestMessageFactory.AddShareSnapshot(directoryBuilder, shareSnapshot);

            StorageRequestMessage request = HttpRequestMessageFactory.GetMetadata(uri, timeout, directoryBuilder, content, operationContext, canonicalizer, credentials);

            request.ApplyAccessCondition(accessCondition);
            return(request);
        }
Beispiel #3
0
        public static HttpRequestMessage ListFilesAndDirectoriesRequest(FileContext context, string shareName, FileListingContext listingContext)
        {
            Uri uri = FileClientTests.ConstructUri(context.Address, shareName);
            OperationContext   opContext = new OperationContext();
            HttpRequestMessage request   = DirectoryHttpRequestMessageFactory.List(uri, context.Timeout, null, listingContext, null, opContext, SharedKeyCanonicalizer.Instance, context.Credentials);

            Assert.IsNotNull(request);
            Assert.IsNotNull(request.Method);
            Assert.AreEqual(HttpMethod.Get, request.Method);
            FileTestUtils.RangeHeader(request, null);
            return(request);
        }