This post is more than 5 years old
2 Posts
0
1236
ViPR Object Services AWS SDK
Good day All
I am having an issue with the ListObjectResponse class in my program it keeps throwing an exception that tells me about something wrong in the XML document, does not stipulate which one.
I am using .NET framework 4.5 with EMC.ViPR.DataServices.AWSSDK v1.0.0 - I don't know whether these clash.
Exception message below:
System.InvalidOperationException: There is an error in XML document (12, 54). ---> System.FormatException: String was not recognized as a valid DateTime.
at System.DateTimeParse.ParseExactMultiple(String s, String[] formats, DateTimeFormatInfo dtfi, DateTimeStyles style)
at System.DateTime.ParseExact(String s, String[] formats, IFormatProvider provider, DateTimeStyles style)
at Amazon.S3.Model.S3Object.set_LastModified(String value)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderListObjectsResponse.Read6_S3Object(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderListObjectsResponse.Read7_ListObjectsResponse(Boolean isNullable, Boolean checkType)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderListObjectsResponse.Read8_ListObjectsResponse()
--- End of inner exception stack trace ---
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)
at Amazon.S3.AmazonS3Client.processRequestResponse (HttpWebResponse httpResponse, S3Request request, Type t, T& response, Exception& cause)
at Amazon.S3.AmazonS3Client.handleHttpResponse (S3Request userRequest, HttpWebRequest request, HttpWebResponse httpResponse, Int32 retries, Int64 lengthOfRequest, T& response, Exception& cause, HttpStatusCode& statusCode)
at Amazon.S3.AmazonS3Client.getResponseCallback (IAsyncResult result)
at Amazon.S3.AmazonS3Client.endOperation (IAsyncResult result)
at Amazon.S3.AmazonS3Client.EndListObjects(IAsyncResult asyncResult)
at Amazon.S3.AmazonS3Client.ListObjects(ListObjectsRequest request)
at ObjectStore1.frmStart.btnGetData_Click(Object sender, EventArgs e) in c:\Users\Chuma\Documents\Visual Studio 2012\Projects\ObjectStore1\ObjectStore1\Form1.cs:line 124
Code is below:
private void btnGetData_Click(object sender, EventArgs e)
var client = CreateClient();
string bucketName = "bucket02";
try
ListObjectsRequest request = new ListObjectsRequest();
//request.Prefix = "Test.txt";
ListObjectsResponse response = new ListObjectsResponse();
foreach (S3Object entry in response.S3Objects)
//richTextBox1.Text.LastModified.ToString());
//foreach (var entry in response.S3Objects)
//{
// MessageBox.Show(entry.Key + " " + entry.Size.ToString() + " " + entry.LastModified);
//}
//var getObjectRequest = new GetObjectRequest()
//{
// BucketName = "bucket02",
// Key = "Test.txt"
//};
//using (var getObjectResponse = client.GetObject(getObjectRequest))
//{
// string objectName = getObjectResponse.Key;
// MessageBox.Show(objectName.ToString());
//}
//GetObjectRequest request = new GetObjectRequest();
//request.BucketName = "bucket02";
//request.Key = "NewFile";
//GetObjectResponse response = client.GetObject(request);
//saveFileDialog1.ShowDialog();
//response.WriteResponseStreamToFile(saveFileDialog1.FileName + ".pdf");
catch (Exception ee)
Would appreciate any help.
Thank you
benschumacher
75 Posts
0
December 8th, 2016 14:00
Are you working with the source code for ViPR Data Service SDK? There is an issue in the S3Object class with hose the lastAccessed property is getting formatted. I was able to get it to work with the following tweak:
this.lastModified = DateTime.ParseExact(
value,
"yyyy-MM-ddTHH:mm:ssZ",
//new string[] { AWSSDKUtils.ISO8601DateFormat, AWSSDKUtils.GMTDateFormat },
CultureInfo.InvariantCulture,
DateTimeStyles.None
);
However, is there any specific reason you're using this specific SDK as it's quite outdated. Can you instead reference the Amazon.S3 nuget package directly in your solution and work with the object store through that SDK instead? Please use the link below to locate the AWS SDK using .NET.
Getting Started with ECS SDKs
Thanks,
Ben
AlanZ1
790 Posts
1
December 8th, 2016 13:00
Your question has been moved to the ViPR community
dyasichuma
2 Posts
0
December 8th, 2016 23:00
Thank you so much Ben,
I used the new API and it worked like a charm.
Regards
Chuma