public Stream Convert(Stream file, string fileName, string outputFileName)
        {
            // Upload input file to cloud storage
            StorageCloudApi.UploadFile(path: fileName, file: file);

            SaveOptionsRequest request = new SaveOptionsRequest()
            {
                FileName = outputFileName,
                Folder   = ""
            };

            // Convert input file (format) to output file (format).
            // Output file will be saved to cloud storage.
            DiagramCloudApi.SaveAs(name: fileName, saveOptionsRequest: request);

            // After conversion, download output file from cloud storage.
            Stream convertResult = StorageCloudApi.DownloadFile(path: outputFileName);

            // Delete both input and output files from cloud storage.
            StorageCloudApi.DeleteFile(path: fileName);
            StorageCloudApi.DeleteFile(path: outputFileName);

            // Return the converted stream
            return(convertResult);
        }
Exemplo n.º 2
0
        public RemoveFileResponse DeleteFileInCloud(string fileName)
        {
            var request  = new DeleteFileRequest(fileName);
            var response = _storageApi.DeleteFile(request);

            return(response);
        }
        public RemoveFileResponse DeletePdf(string fileName)
        {
            var storageApi  = new StorageApi(_apiKey, _appSid);
            var request     = new DeleteFileRequest(fileName);
            var apiResponse = storageApi.DeleteFile(request);

            return(apiResponse);
        }
Exemplo n.º 4
0
        public void TestDeleteFile()
        {
            string Path      = "testfile.txt";
            string versionId = null;
            string storage   = null;

            target.PutCreate(Path, null, null, System.IO.File.ReadAllBytes("\\temp\\resources\\" + Path));
            Com.Aspose.Storage.Model.RemoveFileResponse actual;
            actual = target.DeleteFile(Path, versionId, storage);
            Assert.AreEqual("200", actual.Code);
        }
        private void DeleteFile(string storageName, string path, string versionId = null)
        {
            var request = new DeleteFileRequest();

            request.Path      = path;
            request.Storage   = storageName;
            request.VersionId = versionId;
            var response = StorageApi.DeleteFile(request);

            Assert.AreEqual(200, response.Code);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Remove files from cloud storage
        /// </summary>
        /// <param name="files">List of file names to remove</param>
        public static void StorageCleanUp(List <string> files)
        {
            StorageApi storageApi = new StorageApi(AppKey, AppSid, Basepath);

            foreach (string file in files)
            {
                BusyIndicatorManager.UpdateText("Storage clean up...\n Deleting file: " + file);

                FileExistResponse existsResponse = storageApi.GetIsExist(file, "", "");
                if (existsResponse.FileExist.IsExist)
                {
                    RemoveFileResponse deleteResponse = storageApi.DeleteFile(file, "", "");
                }
            }
        }
Exemplo n.º 7
0
        public void Run()
        {
            // setup name of a storage file
            string name = "testpage1_copy.html";
            // setup a folder path where is the file
            string folder = "/Html/Testout";
            // setup storage name (your default storage if null)
            string storage = null;
            // setup file version ID to delete; null to delete all versions
            string versionId = null;
            var    filePath  = Path.Combine(folder, name).Replace('\\', '/');

            IStorageFileApi stApi    = new StorageApi(CommonSettings.ClientId, CommonSettings.ClientSecret, CommonSettings.BasePath);
            var             response = stApi.DeleteFile(filePath, storage, versionId);

            if (response.Code == 200)
            {
                Console.Out.WriteLine($"File {filePath} has been successfully deleted.");
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Remove files from cloud storage
        /// </summary>
        /// <param name="files">List of file names to remove</param>
        public static void StorageCleanUp(List <string> files)
        {
            string        baseHost             = new Uri(Basepath).GetComponents(UriComponents.SchemeAndServer, UriFormat.SafeUnescaped).ToString();
            Configuration storageConfiguration = new Configuration();

            storageConfiguration.AppKey     = AppKey;
            storageConfiguration.AppSid     = AppSid;
            storageConfiguration.ApiBaseUrl = baseHost;
            StorageApi storageApi = new StorageApi(storageConfiguration);

            foreach (string file in files)
            {
                BusyIndicatorManager.UpdateText("Storage clean up...\n Deleting file: " + file);

                FileExistResponse existsResponse = storageApi.GetIsExist(new GetIsExistRequest(file));
                if (existsResponse.FileExist.IsExist == true)
                {
                    RemoveFileResponse deleteResponse = storageApi.DeleteFile(new DeleteFileRequest(file));
                }
            }
        }
Exemplo n.º 9
0
        public void UpdateDataFile(string folder, string filename)
        {
            StorageApi        storageApi = new StorageApi(clientSecret, clientId);
            DeleteFileRequest file       = new DeleteFileRequest();
            PutCreateRequest  newfile    = new PutCreateRequest();

            if (string.IsNullOrEmpty(folder))
            {
                file.Path    = filename;
                newfile.Path = filename;
                newfile.File = File.Open("example_data/" + filename, FileMode.Open);
            }
            else
            {
                file.Path    = folder + "/" + filename;
                newfile.Path = folder + "/" + filename;
                newfile.File = File.Open("example_data/" + filename, FileMode.Open);
            }
            storageApi.DeleteFile(file);
            storageApi.PutCreate(newfile);
            newfile.File.Close();
        }
Exemplo n.º 10
0
        public static void Run()
        {
            // ExStart:1
            StorageApi storageApi = new StorageApi(Common.APP_KEY, Common.APP_SID, Common.BASEPATH);

            string Path      = "testfile.txt";
            string versionId = null;
            string storage   = null;

            byte[] file = System.IO.File.ReadAllBytes(Common.GetDataDir() + Path);
            try
            {
                // Invoke Aspose.Storage Cloud SDK API to upload and delete file
                storageApi.PutCreate(Path, versionId, storage, file);
                storageApi.DeleteFile(Path, versionId, storage);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
            }
            // ExEnd:1
        }