当前位置: 首页>>代码示例>>C#>>正文


C# Model.GetObjectMetadataRequest类代码示例

本文整理汇总了C#中Amazon.S3.Model.GetObjectMetadataRequest的典型用法代码示例。如果您正苦于以下问题:C# GetObjectMetadataRequest类的具体用法?C# GetObjectMetadataRequest怎么用?C# GetObjectMetadataRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GetObjectMetadataRequest类属于Amazon.S3.Model命名空间,在下文中一共展示了GetObjectMetadataRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: LastWriteTime

 public DateTime LastWriteTime(string id)
 {
     using (var client = SetupClient())
     {
         try {
             var request = new GetObjectMetadataRequest().WithBucketName(BucketName).WithKey(id);
             var response = client.GetObjectMetadata(request);
             var date = response.LastModified;
             var lastwrite = response.Metadata[LastWriteTimeKey];
             return DateTime.Parse(lastwrite);
         }
         catch
         {
             return DateTime.MinValue;
         }
     }
 }
开发者ID:pitlabcloud,项目名称:activity-cloud,代码行数:17,代码来源:FileStorage.cs

示例2: Execute

        /// <summary>
        /// Executes the task.
        /// </summary>
        /// <returns>True if the task executed successfully, false otherwise.</returns>
        public override bool Execute()
        {
            bool exists = false;

            GetObjectMetadataRequest request = new GetObjectMetadataRequest()
                .WithBucketName(BucketName)
                .WithKey(this.Key);

            try
            {
                using (GetObjectMetadataResponse response = Client.GetObjectMetadata(request))
                {
                    exists = true;
                }
            }
            catch (AmazonS3Exception ex)
            {
                if (ex.StatusCode != HttpStatusCode.NotFound || !"NoSuchKey".Equals(ex.ErrorCode, StringComparison.OrdinalIgnoreCase))
                {
                    throw;
                }
            }

            Exists = exists;
            return true;
        }
开发者ID:ChadBurggraf,项目名称:tasty,代码行数:30,代码来源:S3KeyExists.cs

示例3: BucketRegionTestRunner

        public BucketRegionTestRunner(bool useSigV4, bool useSigV4SetExplicitly = false)
        {
            originalUseSignatureVersion4 = AWSConfigsS3.UseSignatureVersion4;
            originalUseSigV4SetExplicitly = GetAWSConfigsS3InternalProperty();
            AWSConfigsS3.UseSignatureVersion4 = useSigV4;
            SetAWSConfigsS3InternalProperty(useSigV4SetExplicitly);

            CreateAndCheckTestBucket();
            if (TestBucketIsReady)
            {
                GetObjectMetadataRequest = new GetObjectMetadataRequest()
                {
                    BucketName = TestBucket.BucketName,
                    Key = TestObjectKey
                };
                PutObjectRequest = new PutObjectRequest()
                {
                    BucketName = TestBucket.BucketName,
                    Key = TestObjectKey,
                    ContentBody = TestContent
                };
                PreSignedUrlRequest = new GetPreSignedUrlRequest
                {
                    BucketName = BucketName,
                    Key = BucketRegionTestRunner.TestObjectKey,
                    Expires = DateTime.Now.AddHours(1)
                };
            }
        }
开发者ID:aws,项目名称:aws-sdk-net,代码行数:29,代码来源:BucketRegionTestRunner.cs

示例4: CreateGetObjectMetadataRequest

        protected internal virtual GetObjectMetadataRequest CreateGetObjectMetadataRequest(string bucket, string path)
        {
            var request = new GetObjectMetadataRequest
                              {
                                  BucketName = bucket,
                                  Key = path,
                              };

            return request;
        }
开发者ID:jrolstad,项目名称:Motore,代码行数:10,代码来源:S3Client.cs

示例5: OnFilePublished

        /// <summary>
        /// Invoked when the publisher has published a file.
        /// </summary>
        /// <param name="path">The local path of the file that was published.</param>
        /// <param name="objectKey">The object key the file was published to.</param>
        /// <param name="withGzip">A value indicating whether the file was GZipped prior to publishing.</param>
        public void OnFilePublished(string path, string objectKey, bool withGzip)
        {
            if (this.assertPublished)
            {
                GetObjectMetadataRequest request = new GetObjectMetadataRequest()
                    .WithBucketName(BucketName)
                    .WithKey(objectKey);

                using (GetObjectMetadataResponse response = Client.GetObjectMetadata(request))
                {
                    Assert.AreEqual(MimeType.FromCommon(objectKey).ContentType, response.ContentType);

                    if (withGzip)
                    {
                        Assert.AreEqual("gzip", response.Headers["Content-Encoding"]);
                    }
                }
            }
        }
开发者ID:ChadBurggraf,项目名称:tasty,代码行数:25,代码来源:S3PublisherTests.cs

示例6: FileExists

        bool FileExists(string key)
        {
            try
            {
                var request = new GetObjectMetadataRequest()
                    .WithBucketName(bucket)
                    .WithKey(key);

                var response = s3client.GetObjectMetadata(request);

                return true;
            }
            catch(AmazonS3Exception ex)
            {
                if(ex.StatusCode == HttpStatusCode.NotFound)
                {
                    return false;
                }
                throw;
            }
        }
开发者ID:dazbradbury,项目名称:SquishIt.S3,代码行数:21,代码来源:S3Renderer.cs

示例7: Test_Blob_Properties_Updated_Async

        public async void Test_Blob_Properties_Updated_Async()
        {
            var container = GetRandomContainerName();
            var blobName = GenerateRandomName();
            var contentType = "image/jpg";
            var newContentType = "image/png";
            var data = GenerateRandomBlobStream();

            await CreateNewObjectAsync(container, blobName, data, false, contentType);

            await _provider.UpdateBlobPropertiesAsync(container, blobName, new BlobProperties
            {
                ContentType = newContentType,
                Security = BlobSecurity.Public
            });

            var objectMetaRequest = new GetObjectMetadataRequest()
            {
                BucketName = Bucket,
                Key = container + "/" + blobName
            };

            var props = await _client.GetObjectMetadataAsync(objectMetaRequest);

            Assert.Equal(props.Headers.ContentType, newContentType);

            var objectAclRequest = new GetACLRequest()
            {
                BucketName = Bucket,
                Key = container + "/" + blobName
            };

            var acl = await _client.GetACLAsync(objectAclRequest);

            var isPublic = acl.AccessControlList.Grants
                .Where(x => x.Grantee.URI == "http://acs.amazonaws.com/groups/global/AllUsers").Count() > 0;

            Assert.True(isPublic);
        }
开发者ID:2020IP,项目名称:TwentyTwenty.Storage,代码行数:39,代码来源:UpdateTestsAsync.cs

示例8: GetFileInfoAsync

        public async Task<FileSpec> GetFileInfoAsync(string path) {
            using (var client = CreateClient()) {
                var req = new GetObjectMetadataRequest {
                    BucketName = _bucket,
                    Key = path.Replace('\\', '/')
                };

                try {
                    var res = await client.GetObjectMetadataAsync(req).AnyContext();

                    if (!res.HttpStatusCode.IsSuccessful())
                        return null;

                    return new FileSpec {
                        Size = res.ContentLength,
                        Created = res.LastModified,
                        Modified = res.LastModified,
                        Path = path
                    };
                } catch (AmazonS3Exception) {
                    return null;
                }
            }
        }
开发者ID:geffzhang,项目名称:Foundatio,代码行数:24,代码来源:S3Storage.cs

示例9: Exists

        public virtual async Task<QueryResult<bool>> Exists(string namePath)
        {
            bool exists = false;
            bool hasExceptions = false;

            try
            {
                IAmazonS3 client = GetS3Client();

                GetObjectMetadataRequest request = new GetObjectMetadataRequest()
                {
                    BucketName = Settings.BucketName,
                    Key = namePath
                };

                GetObjectMetadataResponse response
                    = await client.GetObjectMetadataAsync(request);

                exists = true;
            }
            catch (AmazonS3Exception ex)
            {
                if(ex.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    exists = false;
                }
                else
                {
                    _logger.Exception(ex);
                    hasExceptions = true;
                }
            }

            return new QueryResult<bool>(exists, hasExceptions);
        }
开发者ID:RodionKulin,项目名称:ContentManagementBackend,代码行数:35,代码来源:AmazonFileStorage.cs

示例10: FileExists

    public bool FileExists(string virtualPath) {
      var request = new GetObjectMetadataRequest()
        .WithBucketName(this.bucketName)
        .WithKey(FixPathForS3(virtualPath));

      try {
        using (this.s3.GetObjectMetadata(request)) { }
      } catch (AmazonS3Exception) {
        return false;
      }
      return true;
    }
开发者ID:njmube,项目名称:N2.S3FileSystem,代码行数:12,代码来源:S3FileSystem.cs

示例11: DirectoryExists

    public bool DirectoryExists(string virtualPath) { // ~/upload/28/
      virtualPath = FixPathForS3(virtualPath) + EmptyFilename;

      var request = new GetObjectMetadataRequest()
        .WithBucketName(this.bucketName)
        .WithKey(virtualPath);

      try {
        using (this.s3.GetObjectMetadata(request)) { }
      } catch (AmazonS3Exception) {
        return false;
      }
      return true;
    }
开发者ID:njmube,项目名称:N2.S3FileSystem,代码行数:14,代码来源:S3FileSystem.cs

示例12: GetObjectMetadataAsync

        /// <summary>
        /// Initiates the asynchronous execution of the GetObjectMetadata operation.
        /// <seealso cref="Amazon.S3.IAmazonS3.GetObjectMetadata"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetObjectMetadata operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
		public Task<GetObjectMetadataResponse> GetObjectMetadataAsync(GetObjectMetadataRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetObjectMetadataRequestMarshaller();
            var unmarshaller = GetObjectMetadataResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, GetObjectMetadataRequest, GetObjectMetadataResponse>(request, marshaller, unmarshaller, signer, cancellationToken);
        }
开发者ID:scopely,项目名称:aws-sdk-net,代码行数:16,代码来源:AmazonS3Client.cs

示例13: GetObjectMetadata

        /// <summary>
        /// Returns information about a specified object.
        /// </summary>
        /// <remarks>
        /// Retrieves information about a specific object or object size, without actually fetching the object itself.
        /// This is useful if you're only interested in the object metadata, and don't want to waste bandwidth on the object data.
        /// The response is identical to the GetObject response, except that there is no response body.
        /// </remarks>
        /// <param name="request">Container for the necessary parameters to execute the GetObjectMetadata service method on AmazonS3.</param>
        /// <returns>The response from the HeadObject service method, as returned by AmazonS3.</returns>
		public GetObjectMetadataResponse GetObjectMetadata(GetObjectMetadataRequest request)
        {
            var task = GetObjectMetadataAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
开发者ID:scopely,项目名称:aws-sdk-net,代码行数:22,代码来源:AmazonS3Client.cs

示例14: BeginGetObjectMetadata

        /// <summary>
        /// Initiates the asynchronous execution of the GetObjectMetadata operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetObjectMetadata operation on AmazonS3Client.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndGetObjectMetadata
        ///         operation.</returns>
        public IAsyncResult BeginGetObjectMetadata(GetObjectMetadataRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new GetObjectMetadataRequestMarshaller();
            var unmarshaller = GetObjectMetadataResponseUnmarshaller.Instance;

            return BeginInvoke<GetObjectMetadataRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
开发者ID:JonathanHenson,项目名称:aws-sdk-net,代码行数:19,代码来源:AmazonS3Client.cs

示例15: GetObjectMetadataAsync

        /// <summary>
        /// Initiates the asynchronous execution of the GetObjectMetadata operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetObjectMetadata operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<GetObjectMetadataResponse> GetObjectMetadataAsync(GetObjectMetadataRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetObjectMetadataRequestMarshaller();
            var unmarshaller = GetObjectMetadataResponseUnmarshaller.Instance;

            return InvokeAsync<GetObjectMetadataRequest,GetObjectMetadataResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
开发者ID:sadiqj,项目名称:aws-sdk-xamarin,代码行数:17,代码来源:AmazonS3Client.cs


注:本文中的Amazon.S3.Model.GetObjectMetadataRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。