public void TestCopyMoveFile()
        {
            var testFile = TestFiles.Docx;

            // Create temp folder
            var cRequest = new CreateFolderRequest("temp");
            FolderApi.CreateFolder(cRequest);

            // Copy file
            var destPath = $"temp/{testFile.FileName}";
            var request = new CopyFileRequest(testFile.FullName, destPath);
            FileApi.CopyFile(request);

            // Check copied file
            var eRequest = new ObjectExistsRequest(destPath);
            var eResponse = StorageApi.ObjectExists(eRequest);
            Assert.IsTrue(eResponse.Exists);

            // Move file
            var newDestPath = $"temp/{testFile.FileName.Replace(".", "_1.")}";
            var mRequest = new MoveFileRequest(destPath, newDestPath);
            FileApi.MoveFile(mRequest);

            // Check moved file
            eRequest = new ObjectExistsRequest(newDestPath);
            eResponse = StorageApi.ObjectExists(eRequest);
            Assert.IsTrue(eResponse.Exists);

            // Delete temp folder
            var delRequest = new DeleteFolderRequest("temp", null, true);
            FolderApi.DeleteFolder(delRequest);
        }
Beispiel #2
0
        public static void Run()
        {
            var apiInstance = new FileApi(Constants.GetConfig());

            try
            {
                var request = new CopyFileRequest("one-page.docx", "one-page-copied.docx", Constants.MyStorage, Constants.MyStorage);

                apiInstance.CopyFile(request);
                Console.WriteLine("Expected response type is Void: 'one-page.docx' file copied as 'one-page-copied.docx'.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling FileApi: " + e.Message);
            }
        }
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new FileApi(configuration);

            try
            {
                var request = new CopyFileRequest("viewerdocs/one-page1.docx", "viewerdocs/one-page-copied.docx", Common.MyStorage, Common.MyStorage);

                apiInstance.CopyFile(request);
                Console.WriteLine("Expected response type is Void: 'viewerdocs/one-page1.docx' file copied as 'viewerdocs/one-page-copied.docx'.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling FileApi: " + e.Message);
            }
        }
        public void StorageCopyMoveFile()
        {
            var testFile = TestFiles.PdfStorage.FirstOrDefault(x => x.Name.Equals("01_pages.pdf"));

            // Create temp folder
            var cRequest = new CreateFolderRequest("temp");

            FolderApi.CreateFolder(cRequest);

            // Copy file
            var destPath = $"temp/{testFile.Name}";
            var request  = new CopyFileRequest(testFile.Path, destPath);

            FileApi.CopyFile(request);

            // Check copied file
            var eRequest  = new ObjectExistsRequest(destPath);
            var eResponse = StorageApi.ObjectExists(eRequest);

            Assert.IsTrue(eResponse.Exists);

            // Move file
            var newDestPath = $"temp/{testFile.Path.Replace(".", "_1.")}";
            var mRequest    = new MoveFileRequest(destPath, newDestPath);

            FileApi.MoveFile(mRequest);

            // Check moved file
            eRequest  = new ObjectExistsRequest(newDestPath);
            eResponse = StorageApi.ObjectExists(eRequest);
            Assert.IsTrue(eResponse.Exists);

            // Delete temp folder
            var delRequest = new DeleteFolderRequest("temp", null, true);

            FolderApi.DeleteFolder(delRequest);
        }