Class PendingExportService

java.lang.Object
com.axelor.rpc.PendingExportService

@Singleton public class PendingExportService extends Object
Manages pending export files.

Pending export files are only accessible by the user who created them. They expire after a short period of time and are automatically deleted if not consumed.

  • Constructor Details

    • PendingExportService

      public PendingExportService()
  • Method Details

    • add

      public String add(InputStream stream)
      Adds a pending export file for the current user.

      Creates a temporary file from the given stream and returns the token associated with it.

      Parameters:
      stream - the stream to the export file
      Returns:
      the token associated with the pending export file
    • add

      public String add(InputStream stream, @Nullable String fileName)
      Adds a pending export file for the current user.

      Creates a temporary file from the given stream and returns the token associated with it.

      Parameters:
      stream - the stream to the export file
      fileName - the name of the export file, or null
      Returns:
      the token associated with the pending export file
    • add

      public String add(InputStream stream, @Nullable String fileName, boolean download)
      Adds a pending export file for the current user.

      Creates a temporary file from the given stream and returns the token associated with it.

      Parameters:
      stream - the stream to the export file
      fileName - the name of the export file, or null
      download - whether the client downloads the file, instead of previewing it
      Returns:
      the token associated with the pending export file
    • add

      public String add(Path file)
      Adds a pending export file for the current user.

      Returns the token associated with the given local file. The file is used as is if located in the temporary directory; otherwise, a temporary file is created from it.

      Parameters:
      file - the local export file
      Returns:
      the token associated with the pending export file
    • get

      @Nullable public PendingExportService.PendingExport get(String token)
      Returns the pending export file by its token.

      The pending export file is not consumed, and can be retrieved again until it expires.

      Parameters:
      token - the token associated with the pending export file
      Returns:
      the pending export file, or null if not found, not created by the current user, or its file is missing
    • remove

      @Nullable public PendingExportService.PendingExport remove(String token)
      Removes and returns the pending export file by its token.

      It is your responsibility to delete the export file after you're done with it.

      Parameters:
      token - the token associated with the pending export file
      Returns:
      the pending export file, or null if not found, not created by the current user, or its file is missing