Here is my code to create image url :
List<FileName> lstFileURL = AmazonFunction.GetFileUrlList(BucketName, BucketFolderName, Time);
create amazons3client object :
private static AmazonS3Client GetS3Client()
{
NameValueCollection appConfig = ConfigurationManager.AppSettings;
AmazonS3Client s3Client = (AmazonS3Client)AWSClientFactory.CreateAmazonS3Client(
appConfig["AWSAccessKey"],
appConfig["AWSSecretKey"],
RegionEndpoint.USEast1
);
return s3Client;
}
create image url list :
public static List<FileName> GetFileUrlList(string BUCKET_NAME, string name, double Time)
{
List<FileName> ListImageName = new List<FileName>();
using (GetS3Client())
{
try
{
ListObjectsRequest Lor = new ListObjectsRequest()
{
BucketName = BUCKET_NAME,
// with Prefix is a folder Key, it will list only child of that folder
Prefix = name,
//with Delimiter is '/', it will not get folder.
Delimiter = "/"
};
ListObjectsResponse response1 = GetS3Client().ListObjects(Lor);
//ListBuckets
for (int i = 0; i < response1.S3Objects.Count; i++)
{
ListImageName.Add(new FileName(MakeUrl(BUCKET_NAME, response1.S3Objects[i].Key.ToString().Split('/')response1.S3Objects[i].Key.ToString().Split('/').Length - 1], Time)));
}
}
catch (AmazonS3Exception ex)
{
//Show Exception
}
}
return ListImageName;
}
Here is my code to create video url :
VideoFilePath = AmazonFunction.GetFileURL(BucketName, videotitle, Time);
create video url :
public static string GetFileURL(string BUCKET_NAME, string FILE_NAME, double TIME)
{
using (GetS3Client())
{
try
{
GetObjectRequest gor = new GetObjectRequest()
{
BucketName = BUCKET_NAME,
Key = FILE_NAME,
};
GetObjectResponse response = GetS3Client().GetObject(gor);
string FileURL = MakeUrl(BUCKET_NAME, FILE_NAME, TIME);
return FileURL;
}
catch (AmazonS3Exception ex)
{
return "FileNotFound";
}
}
}
I am getting System.Net.WebException: The operation has timed out on below lines :
List<FileName> lstFileURL = AmazonFunction.GetFileUrlList(BucketName, BucketFolderName, Time);
VideoFilePath = AmazonFunction.GetFileURL(BucketName, videotitle, Time);
I am using MVC 4.
Try adding the below config in your web.config.