public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems)
        {
            AmazonMediaStoreConfig config = new AmazonMediaStoreConfig();

            config.RegionEndpoint = region;
            ConfigureClient(config);
            AmazonMediaStoreClient client = new AmazonMediaStoreClient(creds, config);

            ListContainersResponse resp = new ListContainersResponse();

            do
            {
                ListContainersRequest req = new ListContainersRequest
                {
                    NextToken = resp.NextToken
                    ,
                    MaxResults = maxItems
                };

                resp = client.ListContainers(req);
                CheckError(resp.HttpStatusCode, "200");

                foreach (var obj in resp.Containers)
                {
                    AddObject(obj);
                }
            }while (!string.IsNullOrEmpty(resp.NextToken));
        }
        /// <summary>
        /// Читаем из AWS
        /// </summary>
        /// <param name="creds"></param>
        /// <returns></returns>
        static async Task GetFileFromAWS(Credentials creds)
        {
            var credentials = new BasicAWSCredentials(creds.AccessKey, creds.SecretKey);

            using (var client = new AmazonMediaStoreClient(credentials, RegionEndpoint.EUCentral1))
                using (var storeDataClient = await CreateStoreDataClientAsync(client: client, containerName: "test", credentials: credentials))
                {
                    await GetObjectAsync(storeDataClient, creds.DirctoryPath + "/sample.mp4");
                }
        }
Exemplo n.º 3
0
        protected IAmazonMediaStore CreateClient(AWSCredentials credentials, RegionEndpoint region)
        {
            var config = new AmazonMediaStoreConfig {
                RegionEndpoint = region
            };

            Amazon.PowerShell.Utils.Common.PopulateConfig(this, config);
            this.CustomizeClientConfig(config);
            var client = new AmazonMediaStoreClient(credentials, config);

            client.BeforeRequestEvent += RequestEventHandler;
            client.AfterResponseEvent += ResponseEventHandler;
            return(client);
        }
        private static async Task <AmazonMediaStoreDataClient> CreateStoreDataClientAsync(AmazonMediaStoreClient client, string containerName, BasicAWSCredentials credentials)
        {
            //var request = new ListContainersRequest();
            //var containers = await client.ListContainersAsync(request);
            //var container = containers.Containers.SingleOrDefault(c => c.Name == containerName);
            var config = new AmazonMediaStoreDataConfig
            {
                ServiceURL = "https://qdzszkjdcpfevy.data.mediastore.eu-central-1.amazonaws.com"
            };

            return(new AmazonMediaStoreDataClient(credentials, config));
        }