public override void Invoke(AWSCredentials creds, RegionEndpoint region, int maxItems) { AmazonMediaStoreDataConfig config = new AmazonMediaStoreDataConfig(); config.RegionEndpoint = region; ConfigureClient(config); AmazonMediaStoreDataClient client = new AmazonMediaStoreDataClient(creds, config); ListItemsResponse resp = new ListItemsResponse(); do { ListItemsRequest req = new ListItemsRequest { NextToken = resp.NextToken , MaxResults = maxItems }; resp = client.ListItems(req); CheckError(resp.HttpStatusCode, "200"); foreach (var obj in resp.Items) { AddObject(obj); } }while (!string.IsNullOrEmpty(resp.NextToken)); }
protected IAmazonMediaStoreData CreateClient(AWSCredentials credentials, RegionEndpoint region) { var config = new AmazonMediaStoreDataConfig { RegionEndpoint = region }; Amazon.PowerShell.Utils.Common.PopulateConfig(this, config); this.CustomizeClientConfig(config); var client = new AmazonMediaStoreDataClient(credentials, config); client.BeforeRequestEvent += RequestEventHandler; client.AfterResponseEvent += ResponseEventHandler; return(client); }
private static async Task PutObjectToContainerAsync(AmazonMediaStoreDataClient storeDataClient, string path) { var putRequest = new PutObjectRequest(); using (var sr = new StreamReader("./SampleVideo/big_buck_bunny.mp4")) { putRequest.Body = sr.BaseStream; putRequest.Path = path; var response = await storeDataClient.PutObjectAsync(putRequest); Console.WriteLine($"File was sent to AWS with status {response.HttpStatusCode}"); } }
private static async Task <Stream> GetObjectAsync(AmazonMediaStoreDataClient storeDataClient, string path) { var request = new GetObjectRequest { Path = path }; try { var response = await storeDataClient.GetObjectAsync(request); Console.WriteLine($"Get file from AWS with code {response.StatusCode}"); return(response.Body); } catch (Exception e) { Console.WriteLine($"Something goes wrong when getting item from AWS: {e.Message}"); } return(null); }