internal static string GetSingleObjectWithRange(IDs3Client client, string bucketName, string objectName, Range range, IHelperStrategy<Ds3PartialObject> helperStrategy = null) { var tempFilename = Path.GetTempFileName(); using (Stream fileStream = new FileStream(tempFilename, FileMode.Truncate, FileAccess.Write)) { IDs3ClientHelpers helper = new Ds3ClientHelpers(client); if (helperStrategy == null) { helperStrategy = new ReadRandomAccessHelperStrategy<Ds3PartialObject>(); } var job = helper.StartPartialReadJob(bucketName, new List<string>(), new List<Ds3PartialObject> {new Ds3PartialObject(range, objectName)}, helperStrategy: helperStrategy); job.Transfer(key => fileStream); return tempFilename; } }
public static void LoadTestData(IDs3Client client, string bucketName, IHelperStrategy<string> helperStrategy = null) { PutFiles(client, bucketName, Objects, ReadResource, helperStrategy); }
public static void PutFiles(IDs3Client client, string bucketName, IEnumerable<Ds3Object> files, Func<string, Stream> createStreamForTransferItem, IHelperStrategy<string> helperStrategy = null) { IDs3ClientHelpers helper = new Ds3ClientHelpers(client); helper.EnsureBucketExists(bucketName); var job = helper.StartWriteJob(bucketName, files, helperStrategy: helperStrategy); job.Transfer(createStreamForTransferItem); }
/// <summary> /// This will get the object and return the name of the temporary file it was written to. /// It is up to the caller to delete the temporary file /// </summary> public static string GetSingleObject(IDs3Client client, string bucketName, string objectName, int retries = 5, IHelperStrategy<string> helperStrategy = null) { var tempFilename = Path.GetTempFileName(); using (Stream fileStream = new FileStream(tempFilename, FileMode.Truncate, FileAccess.Write)) { IDs3ClientHelpers helper = new Ds3ClientHelpers(client, objectTransferAttempts: retries); if (helperStrategy == null) { helperStrategy = new ReadRandomAccessHelperStrategy<string>(); } var job = helper.StartReadJob(bucketName, new List<Ds3Object> {new Ds3Object(objectName, null)}, helperStrategy: helperStrategy); job.Transfer(key => fileStream); return tempFilename; } }