internal Upload(IObjectOperations objectOperations, IMultipartOperations multipartOperations, string bucket, string objectKey) { _objectOperations = objectOperations; _multipartOperations = multipartOperations; _request = new PutObjectRequest(bucket, objectKey, null); }
/// <summary> /// Gets AD group membership by provided AD object Ids /// </summary> /// <param name='operations'> /// Reference to the Microsoft.Azure.Graph.RBAC.IObjectOperations. /// </param> /// <param name='parameters'> /// Required. Objects filtering parameters. /// </param> /// <returns> /// Server response for Active Directory objects inquiry API calls /// </returns> public static GetObjectsResult GetObjectsByObjectIds(this IObjectOperations operations, GetObjectsParameters parameters) { return(Task.Factory.StartNew((object s) => { return ((IObjectOperations)s).GetObjectsByObjectIdsAsync(parameters); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Gets the details for current logged in user /// </summary> /// <param name='operations'> /// Reference to the Microsoft.Azure.Graph.RBAC.IObjectOperations. /// </param> /// <returns> /// Server response for Active Directory objects inquiry API calls /// </returns> public static GetCurrentUserResult GetCurrentUser(this IObjectOperations operations) { return(Task.Factory.StartNew((object s) => { return ((IObjectOperations)s).GetCurrentUserAsync(); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }
/// <summary> /// Initializes a new instance of the GraphRbacManagementClient class. /// </summary> /// <param name='httpClient'> /// The Http client /// </param> public GraphRbacManagementClient(HttpClient httpClient) : base(httpClient) { this._application = new ApplicationOperations(this); this._group = new GroupOperations(this); this._objects = new ObjectOperations(this); this._servicePrincipal = new ServicePrincipalOperations(this); this._user = new UserOperations(this); this._apiVersion = "1.42-previewInternal"; this._longRunningOperationInitialTimeout = -1; this._longRunningOperationRetryTimeout = -1; this.HttpClient.Timeout = TimeSpan.FromSeconds(300); }
private static async Task <GetObjectResponse> DownloadPartAsync(IObjectOperations operations, string bucketName, string objectKey, Stream output, long partSize, int partNumber, int bufferSize, SemaphoreSlim semaphore, Mutex mutex, Action <GetObjectRequest>?config, CancellationToken token) { try { GetObjectRequest getReq = new GetObjectRequest(bucketName, objectKey); getReq.PartNumber = partNumber; config?.Invoke(getReq); GetObjectResponse getResp = await operations.GetObjectAsync(getReq, token).ConfigureAwait(false); using (Stream stream = getResp.Content) { long offset = (partNumber - 1) * partSize; byte[] buffer = new byte[bufferSize]; while (true) { int read = await stream.ReadUpToAsync(buffer, 0, bufferSize, token).ConfigureAwait(false); if (read > 0) { mutex.WaitOne(); output.Seek(offset, SeekOrigin.Begin); await output.WriteAsync(buffer, 0, read, token).ConfigureAwait(false); offset += read; mutex.ReleaseMutex(); } else { break; } } } return(getResp); } finally { semaphore.Release(); } }
public MinioS3Client(IBucketOperations bucketOperationsClient, IObjectOperations objectOperationsClient, string endpoint, string bucketName, ILogger <IS3Client> logger, int retryCount, int retryInSeconds) { if (retryCount < 0 || retryInSeconds < 0) { throw new S3BaseException("Retry count and retry in seconds parameters should be > 0"); } _endpoint = endpoint; _objectOperationsClient = objectOperationsClient; _bucketOperationsClient = bucketOperationsClient; _bucketName = bucketName.ToLower(); _logger = logger; _retryCount = retryCount; _retryInSeconds = retryInSeconds; _requestRetryPolicy = Policy.Handle <ConnectionException>().Or <InternalServerException>().Or <InternalClientException>() .WaitAndRetryAsync(_retryCount, retryAttempt => TimeSpan.FromSeconds(_retryInSeconds), (ex, time, retryAttempt, ctx) => { var message = $"Problem connecting to S3 endpoint. Retrying {retryAttempt}/{_retryCount}. Endpoint={_endpoint}"; _logger?.LogWarning(ex, message); Debug.WriteLine(message); }); }
public static async IAsyncEnumerable <GetObjectResponse> MultipartDownloadAsync(this IObjectOperations operations, string bucketName, string objectKey, Stream output, int bufferSize = 16777216, int numParallelParts = 4, Action <GetObjectRequest>?config = null, [EnumeratorCancellation] CancellationToken token = default) { Validator.RequireNotNull(output, nameof(output)); //Use a HEAD request on the object key to determine if the file was originally uploaded with multipart HeadObjectRequest headReq = new HeadObjectRequest(bucketName, objectKey); headReq.PartNumber = 1; HeadObjectResponse headResp = await operations.HeadObjectAsync(headReq, token).ConfigureAwait(false); Queue <Task <GetObjectResponse> > queue = new Queue <Task <GetObjectResponse> >(); if (headResp.NumberOfParts == null) { GetObjectRequest getReq = new GetObjectRequest(bucketName, objectKey); config?.Invoke(getReq); GetObjectResponse getResp = await operations.GetObjectAsync(getReq, token).ConfigureAwait(false); if (!getResp.IsSuccess) { throw new Exception(); } await getResp.Content.CopyToAsync(output, 81920, token).ConfigureAwait(false); yield return(getResp); } else { int parts = headResp.NumberOfParts.Value; using (SemaphoreSlim semaphore = new SemaphoreSlim(numParallelParts)) using (Mutex mutex = new Mutex()) { for (int i = 1; i <= parts; i++) { await semaphore.WaitAsync(token).ConfigureAwait(false); if (token.IsCancellationRequested) { yield break; } queue.Enqueue(DownloadPartAsync(operations, bucketName, objectKey, output, headResp.ContentLength, i, bufferSize, semaphore, mutex, config, token)); } while (queue.TryDequeue(out Task <GetObjectResponse>?task)) { if (token.IsCancellationRequested) { yield break; } GetObjectResponse response = await task !.ConfigureAwait(false); yield return(response); } } } }
internal Upload(IObjectOperations objectOperations, string bucket, string resource, Stream stream, bool ownStream = false) { _request = new PutObjectRequest(bucket, resource, stream); _objectOperations = objectOperations; _ownStream = ownStream; }
public S3ObjectClient(IObjectOperations operations) { _operations = operations; }
public S3MultipartClient(IMultipartOperations multipartOperations, IObjectOperations objectOperations) { _objectOperations = objectOperations; MultipartOperations = multipartOperations; }
public Transfer(IObjectOperations objectOperations) { _objectOperations = objectOperations; }
internal Download(IObjectOperations objectOperations, string bucket, string resource) { _request = new GetObjectRequest(bucket, resource); _objectOperations = objectOperations; }
public Transfer(IObjectOperations objectOperations, IMultipartOperations multipartOperations) { _objectOperations = objectOperations; _multipartOperations = multipartOperations; }
public Transfer(IObjectOperations objectOperations, IMultipartTransfer multipartTransfer) { _objectOperations = objectOperations; _multipartTransfer = multipartTransfer; }
/// <summary> /// Gets the details for current logged in user /// </summary> /// <param name='operations'> /// Reference to the Microsoft.Azure.Graph.RBAC.IObjectOperations. /// </param> /// <returns> /// Server response for Active Directory objects inquiry API calls /// </returns> public static Task <GetCurrentUserResult> GetCurrentUserAsync(this IObjectOperations operations) { return(operations.GetCurrentUserAsync(CancellationToken.None)); }
public PooledObjectClient(IObjectOperations operations) { ObjectOperations = operations; }
internal Download(IObjectOperations objectOperations, string bucket, string objectKey) { _request = new GetObjectRequest(bucket, objectKey); _objectOperations = objectOperations; }
internal Download(IObjectOperations operations, IMultipartTransfer multipartTransfer, string bucket, string objectKey) { _request = new GetObjectRequest(bucket, objectKey); _operations = operations; _multipartTransfer = multipartTransfer; }
/// <summary> /// Gets AD group membership by provided AD object Ids /// </summary> /// <param name='operations'> /// Reference to the Microsoft.Azure.Graph.RBAC.IObjectOperations. /// </param> /// <param name='parameters'> /// Required. Objects filtering parameters. /// </param> /// <returns> /// Server response for Active Directory objects inquiry API calls /// </returns> public static Task <GetObjectsResult> GetObjectsByObjectIdsAsync(this IObjectOperations operations, GetObjectsParameters parameters) { return(operations.GetObjectsByObjectIdsAsync(parameters, CancellationToken.None)); }