示例#1
0
        public void FileDeleteFileTest()
        {
            DeleteFileRequest request = new DeleteFileRequest();

            request.path      = Path.Combine(dataFolder, "TestFile.pdf");
            request.storage   = storageName;
            request.versionId = null;
            var response = FileApi.DeleteFile(request);

            Assert.AreEqual(200, response.Code);
        }
        public void TestDeleteFile()
        {
            // Arrange
            var testFile = TestFiles.Docx;
            var deleteRequest = new DeleteFileRequest {path = testFile.FullName};
            var existsRequest = new ObjectExistsRequest { path = testFile.FullName };
            var uploadRequest = new UploadFileRequest(testFile.FullName, GetTestFileStream(testFile));

            // Act & Assert
            FileApi.DeleteFile(deleteRequest);
            var response = StorageApi.ObjectExists(existsRequest);
            Assert.IsFalse(response.Exists);
            FileApi.UploadFile(uploadRequest);
            response = StorageApi.ObjectExists(existsRequest);
            Assert.IsTrue(response.Exists);
        }
        public static void Run()
        {
            var apiInstance = new FileApi(Constants.GetConfig());

            try
            {
                var request = new DeleteFileRequest("one-page1.docx", Constants.MyStorage);

                apiInstance.DeleteFile(request);
                Console.WriteLine("Expected response type is Void: 'one-page1.docx' deleted.");
            }
            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 DeleteFileRequest("Annotationdocs1/one-page1.docx", Common.MyStorage);

                apiInstance.DeleteFile(request);
                Console.WriteLine("Expected response type is Void: 'Annotationdocs1/one-page1.docx' deleted.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling FileApi: " + e.Message);
            }
        }
        public void StorageDeleteFile()
        {
            // Arrange
            var testFile      = TestFiles.PdfStorage.FirstOrDefault(x => x.Name.Equals("01_pages.pdf"));
            var deleteRequest = new DeleteFileRequest {
                path = testFile.Path
            };
            var existsRequest = new ObjectExistsRequest {
                path = testFile.Path
            };
            var uploadRequest = new UploadFileRequest(testFile.Path, GetTestFileStream(testFile));

            // Act & Assert
            FileApi.DeleteFile(deleteRequest);
            var response = StorageApi.ObjectExists(existsRequest);

            Assert.IsFalse(response.Exists);
            FileApi.UploadFile(uploadRequest);
            response = StorageApi.ObjectExists(existsRequest);
            Assert.IsTrue(response.Exists);
        }
        public string Convert(Stream file, string fileName, string language)
        {
            LanguageEnum lg = LanguageEnum.English;

            System.Enum.TryParse <LanguageEnum>(language, true, out lg);

            UploadFileRequest uploadFileRequest = new UploadFileRequest()
            {
                path = fileName,
                File = file
            };

            OCRFileApi.UploadFile(uploadFileRequest);

            GetRecognizeDocumentRequest request = new GetRecognizeDocumentRequest(name: fileName, language: lg);
            OCRResponse response = OCRCloudApi.GetRecognizeDocument(request);

            OCRFileApi.DeleteFile(new DeleteFileRequest(path: fileName));

            return(response.Text);
        }