2

画像のURLを作成するコードは次のとおりです。

List<FileName> lstFileURL = AmazonFunction.GetFileUrlList(BucketName, BucketFolderName, Time);

amazons3client オブジェクトを作成します:

private static AmazonS3Client GetS3Client()
            {
                NameValueCollection appConfig = ConfigurationManager.AppSettings;

                AmazonS3Client s3Client = (AmazonS3Client)AWSClientFactory.CreateAmazonS3Client(
                        appConfig["AWSAccessKey"],
                        appConfig["AWSSecretKey"],
                        RegionEndpoint.USEast1
                        );
                return s3Client;
            }

画像の URL リストを作成:

    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;
                }

ビデオのURLを作成するコードは次のとおりです。

VideoFilePath = AmazonFunction.GetFileURL(BucketName, videotitle, Time);

動画の 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";
                        }
                    }
                }

System.Net.WebException: The operation has time out on below lines を取得しています:

List<FileName> lstFileURL = AmazonFunction.GetFileUrlList(BucketName, BucketFolderName, Time);
VideoFilePath = AmazonFunction.GetFileURL(BucketName, videotitle, Time);

MVC4を使用しています。

4

1 に答える 1