13.2.8. Transferring Files

Engineering Knowledge Manager

Administration Guide | Chapter 13: EKM Client API | 13.2. Using the Library in Client Applications |

13.2.7. Version Control |  | 13.2.9. Managing Users and Groups
Prev |  | Next

### 13.2.8. Transferring Files

One of the more common tasks that an application may wish to perform is transferring files between the client and the EKM server. Whenever an application transfers files, it must provide a `TransferEventListener`. This is an object that will receive events about the transfer. Events include the start, cancellation, failure, or completion of a transfer. Additionally, it will receive events with progress information about the transfer.

The following examples show how to upload and download a file:

Java

      ModelObject destination = dm.findByPath(“/Data/My Data/My Projects”);
      List<String> files = new ArrayList<>();
      files.add(“/projects/my-project.wbpj”);
      TransferEventListener listener = new MyTransferEventListener();
      dm.upload(files, destination.getPath(), new ArrayList<String>(), listener), true;
      //
      // Wait for the upload to complete and check the status
      // to ensure it was successful.
      //
      List<String> toDownload = new ArrayList<>();
      toDownload.add("/Data/My Data/My Projects/my-project.wbpz");
      dm.download(toDownload , System.getenv("TEMP"), true, listener);
      //
      // Wait for the download to complete and check the status
      // to ensure it was successful.
      //

Python (Jython)

      toUpload = [“/projects/my-project.wbpz”]
      destination = dm.findByPath(“/Data/My Data/My Projects”)
      listener = MyTransferEventListener()
      dm.upload(toUpload, destination.getPath(), None, listener, True)
      #
      # Wait for the upload to complete and check the status
      # to ensure it was successful.
      #
      toDownload = ["/Data/My Data/My Projects/my-project.wbpz"]
      dm.download(toDownload, os.environ[“TEMP”], True, listener)
      #
      # Wait for the download to complete and check the status
      # to ensure it was successful.
      #

Python (IronPython)

      toUpload = List[str]()
      toUpload .Add(“/projects/my-project.wbpz”)
      destination = dm.FindByPath("/Data/My Data/My Projects")
      listener = MyTransferEventListener()
      dm.Upload(toUpload, destination.Path, listener, True)
      #
      # Wait for the upload to complete and check the status
      # to ensure it was successful.
      #
      toDownload = List[str]()
      toDownload .Add("/Data/My Data/My Projects/my-project.wbpz")
      dm.Download(toDownload, os.environ["TEMP"], True, listener)
      #
      # Wait for the download to complete and check the status
      # to ensure it was successful.
      #

C#

      List<string> toUpload = new List<string>();
      toUpload.Add(“/projects/my-project.wbpz”);
      ModelObject destination = dm.FindByPath(“/Data/My Data/My Projects”);
      TransferEventListener listener = new MyTransferEventListener();
      dm.Upload(toUpload, destination.Path, listener, true);
      //
      // Wait for the upload to complete and check the status
      // to ensure it was successful.
      //
      List<string> toDownload = new List<string>();
      toDownload.Add("/Data/My Data/My Projects/my-project.wbpz");
      dm.Download(toDownload, Environment.GetEnvironmentVariable("TEMP"), true, listener);
      //
      // Wait for the download to complete and check the status
      // to ensure it was successful.
      //

Contains proprietary and confidential information of ANSYS, Inc. and its subsidiaries and affiliates.

Prev | Up / Contents | Next

Release 18.2 - © ANSYS, Inc. All rights reserved.