private void PutCopyFile(string storageName, string srcPath, string destStorageName, string destPath, string versionId = null) { var request = new PutCopyRequest(); request.Path = srcPath; request.Storage = storageName; request.VersionId = versionId; request.Newdest = destPath; request.DestStorage = destStorageName; CopyFileResponse response = null; try { response = StorageApi.PutCopy(request); } catch (Exception ex) { var msg = new string[] { "Invalid version id specified", //AmazonS3 "Invalid snapshot time", //Windows Azure "Value should match pattern", //DropBox }; Assert.IsTrue(msg.Where(x => ex.Message.Contains(x)).Any(), ex.Message); return; } Assert.AreEqual(200, response.Code); }
public string CloneTemplate(string fileName) { var storageApi = CreateStorageApi(); var newFileName = $"{Guid.NewGuid().ToString()}-{fileName}"; var copyRequest = new PutCopyRequest(fileName, newFileName); storageApi.PutCopy(copyRequest); return(newFileName); }
/// <summary> /// Copy a specific file /// </summary> /// <param name="request">Request. <see cref="PutCopyRequest" /></param> /// <returns><see cref="CopyFileResponse"/></returns> public CopyFileResponse PutCopy(PutCopyRequest request) { // verify the required parameter 'path' is set if (request.Path == null) { throw new ApiException(400, "Missing required parameter 'path' when calling PutCopy"); } // verify the required parameter 'newdest' is set if (request.Newdest == null) { throw new ApiException(400, "Missing required parameter 'newdest' when calling PutCopy"); } // create path and map variables var resourcePath = this.configuration.GetApiRootUrl() + "/storage/file"; resourcePath = Regex .Replace(resourcePath, "\\*", string.Empty) .Replace("&", "&") .Replace("/?", "?"); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "path", request.Path); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "newdest", request.Newdest); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "versionId", request.VersionId); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "storage", request.Storage); resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "destStorage", request.DestStorage); try { var response = this.apiInvoker.InvokeApi( resourcePath, "PUT", null, null, null); if (response != null) { return((CopyFileResponse)SerializationHelper.Deserialize(response, typeof(CopyFileResponse))); } return(null); } catch (ApiException ex) { if (ex.ErrorCode == 404) { return(null); } throw; } }
public void FilePutCopyTest() { PutCopyRequest request = new PutCopyRequest(); request.path = Path.Combine(dataFolder, "/folder2/TestFile1.pdf"); request.storage = storageName; request.versionId = null; request.newdest = Path.Combine(dataFolder, "folder3/TestFile1.pdf"); request.destStorage = destStorageName; var response = FileApi.PutCopy(request); Assert.AreEqual(200, response.Code); }