public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { RestoreObjectResponse response = new RestoreObjectResponse(); return(response); }
public async Task RestoreWithSelect() { using (StringWriter sw = new StringWriter()) { sw.WriteLine("name,age,status"); sw.WriteLine("santa,800,missing"); sw.WriteLine("\"donald trump\",7,present"); sw.WriteLine("fantastic fox,31,missing"); await ObjectClient.PutObjectStringAsync(BucketName, nameof(RestoreWithSelect), sw.ToString(), Encoding.UTF8, req => req.StorageClass = StorageClass.Glacier).ConfigureAwait(false); } RestoreObjectResponse restoreResp = await ObjectClient.RestoreObjectAsync(BucketName, nameof(RestoreWithSelect), req => { req.RequestType = RestoreRequestType.Select; req.Description = "This is a description"; req.RequestTier = RetrievalTier.Standard; S3CsvInputFormat inputFormat = new S3CsvInputFormat(); inputFormat.HeaderUsage = HeaderUsage.Use; S3CsvOutputFormat outputFormat = new S3CsvOutputFormat(); req.SelectParameters = new S3SelectParameters("SELECT * FROM object WHERE age > 7", inputFormat, outputFormat); req.OutputLocation = new S3OutputLocation(BucketName, "outputJob"); req.OutputLocation.StorageClass = StorageClass.Standard; }).ConfigureAwait(false); Assert.Equal(202, restoreResp.StatusCode); //TODO: List objects beneath outputJob/* and GET file to determine if format is correct }
public async Task Restore() { //Upload an object to glacier PutObjectResponse putResp = await UploadAsync(nameof(Restore), req => req.StorageClass = StorageClass.Glacier).ConfigureAwait(false); Assert.Equal(StorageClass.Glacier, putResp.StorageClass); RestoreObjectResponse restoreResp = await ObjectClient.RestoreObjectAsync(BucketName, nameof(Restore), req => req.Days = 2).ConfigureAwait(false); Assert.Equal(202, restoreResp.StatusCode); }
public override AmazonWebServiceResponse Unmarshall(XmlUnmarshallerContext context) { RestoreObjectResponse restoreObjectResponse = new RestoreObjectResponse(); IWebResponseData responseData = context.get_ResponseData(); if (responseData.IsHeaderPresent(S3Constants.AmzHeaderRequestCharged)) { restoreObjectResponse.RequestCharged = RequestCharged.FindValue(responseData.GetHeaderValue(S3Constants.AmzHeaderRequestCharged)); } return(restoreObjectResponse); }
public async Task Restore(S3Provider _, string bucket, ISimpleClient client) { //Upload an object to glacier PutObjectResponse putResp = await client.PutObjectAsync(bucket, nameof(Restore), null, r => r.StorageClass = StorageClass.Glacier).ConfigureAwait(false); Assert.Equal(StorageClass.Glacier, putResp.StorageClass); RestoreObjectResponse restoreResp = await client.RestoreObjectAsync(bucket, nameof(Restore), r => r.Days = 2).ConfigureAwait(false); Assert.Equal(202, restoreResp.StatusCode); }
/// <summary> /// This method restores an archived object from an Amazon S3 bucket. /// </summary> /// <param name="client">The initialized S3 client object used to call /// RestoreObjectAsync.</param> /// <param name="bucketName">A string representing the name of the /// bucket where the object to restore was located.</param> /// <param name="objectKey">A string representing the name of the /// archived object to restore.</param> public static async Task RestoreObjectAsync(IAmazonS3 client, string bucketName, string objectKey) { try { var restoreRequest = new RestoreObjectRequest { BucketName = bucketName, Key = objectKey, Days = 2, }; RestoreObjectResponse response = await client.RestoreObjectAsync(restoreRequest); // Check the status of the restoration. await CheckRestorationStatusAsync(client, bucketName, objectKey); } catch (AmazonS3Exception amazonS3Exception) { Console.WriteLine($"Error: {amazonS3Exception.Message}"); } }
private static void RestoreObject() { try { RestoreObjectRequest request = new RestoreObjectRequest() { BucketName = bucketName, ObjectKey = objectName, Days = 5, Tier = RestoreTierEnum.Expedited, VersionId = versionId }; RestoreObjectResponse response = client.RestoreObject(request); Console.WriteLine("Get restore object response: {0}", response.StatusCode); } catch (ObsException ex) { Console.WriteLine("Exception errorcode: {0}, when get restore object.", ex.ErrorCode); Console.WriteLine("Exception errormessage: {0}", ex.ErrorMessage); } }
static async Task RestoreObjectAsync(IAmazonS3 client, string bucketName, string objectKey) { try { var restoreRequest = new RestoreObjectRequest { BucketName = bucketName, Key = objectKey, Days = 2 }; RestoreObjectResponse response = await client.RestoreObjectAsync(restoreRequest); // Check the status of the restoration. await CheckRestorationStatusAsync(client, bucketName, objectKey); } catch (AmazonS3Exception amazonS3Exception) { Console.WriteLine("An AmazonS3Exception was thrown. Exception: " + amazonS3Exception.ToString()); } catch (Exception e) { Console.WriteLine("Exception: " + e.ToString()); } }