예제 #1
0
 // [END build_service]
 // [START list_storage_bucket_contents]
 /// <summary>
 /// List the contents of a Cloud Storage bucket.
 /// </summary>
 /// <param name="bucket">the name of the Cloud Storage bucket.</param>
 ///<returns>a list of the contents of the specified bucket.</returns>
 public Objects ListBucketContents(
     StorageService storage, string bucket)
 {
     var request = new
         Google.Apis.Storage.v1.ObjectsResource.ListRequest(storage,
         bucket);
     var requestResult = request.Execute();
     return requestResult;
 }
예제 #2
0
        // [END build_service]

        // [START list_storage_bucket_contents]
        /// <summary>
        /// List the contents of a Cloud Storage bucket.
        /// </summary>
        /// <param name="bucket">the name of the Cloud Storage bucket.</param>
        ///<returns>a list of the contents of the specified bucket.</returns>
        public Objects ListBucketContents(
            StorageService storage, string bucket)
        {
            var request = new
                          Google.Apis.Storage.v1.ObjectsResource.ListRequest(storage,
                                                                             bucket);
            var requestResult = request.Execute();

            return(requestResult);
        }
예제 #3
0
        public Google.Apis.Storage.v1.Data.Objects ListBucketContents(Google.Apis.Storage.v1.StorageService storage, string bucket)
        {
            //https://cloud.google.com/docs/authentication#code_samples
            var request = new
                          Google.Apis.Storage.v1.ObjectsResource.ListRequest(storage,
                                                                             bucket);
            var requestResult = request.Execute();

            return(requestResult);
        }
예제 #4
0
        public override FileItem[] ListFiles(FileItem from)
        {
            Google.Apis.Storage.v1.Data.Objects objectListing = new Google.Apis.Storage.v1.ObjectsResource.ListRequest(service, from.BucketName).Execute();
            FileItem[] mFileItems = new FileItem[objectListing.Items.Count];
            int        i          = 0;

            foreach (Google.Apis.Storage.v1.Data.Object obj in objectListing.Items)
            {
                FileItem mFileItem = new FileItem();
                mFileItem.BucketName   = obj.Bucket;
                mFileItem.Path         = obj.Name;
                mFileItem.IsDirectory  = obj.Name.EndsWith("/");
                mFileItem.LastModified = ((DateTime)obj.TimeCreated).Ticks;
                mFileItem.Size         = (long)obj.Size;
                mFileItems[i]          = mFileItem;
                i++;
            }
            return(mFileItems);
        }