When using FASP Stream for transferring Files to Stream or transferring a Stream to a File you have the ability to provide a byte-stream write interface into an Aspera Server or a byte-stream read interface out of an Aspera Server.  By using this approach you can easily receive data on an Aspera Server as it is being generating by your application or have your application receive and process a stream being sent from a file on an Aspera Server.

Prerequisites

In order to use FASP Stream's File to Stream or Stream to File approach you need to ensure that the ascp binary on the machine that is sending the stream is at least version 3.6.  The ascp binary on the other machine needs to be at least version 3.5.2. You can check what version of ascp you have by running 'ascp -A' on the machine in question.

Stream to FileFASPStream to file

The FASP Stream SDK can be used to transfer in-memory data to an Aspera Server that can save it as a file.  Custom applications integrating the FASP Stream SDK may create an output stream using FASP and write data to the pipe in order to transfer the bytes to the Aspera Server.  The example below shows the normal steps and includes comments explaining the use of the SDK in the C# project.

Java

The general structure of a FASPStream SDK Java application in stream to file mode is the following:

  1. Create an instance of an output stream using the faspstream.

    public static FaspOutputStreamSAE fos = new FaspOutputStreamSAE();
  2. Set the transfer authentication information

    fos.setUsername("asperaweb");fos.setPassword("demoaspera");
  3. Set transfer parameters (eg. target rate, destination file name).

    fos.setTargetRate(10000);fos.setDestinationFilename(f.getName());fos.setDestinationDirectory("/Upload");
  4. Initiate the session to the remote Aspera Server.

    fos.connect(host, f.length());
  5. Loop over the input data and write to the faspstream output stream to transfer.

    fos.write(data, 0, count);
  6. When finished, close the output stream.

    in.close();fos.close();

Full Example

 

C#

The general structure of a FASPStream SDK C# application in stream to file mode is as follows.

  1. Create an instance of an output stream using the faspstream.

    FaspOutputStream fos = new FaspOutputStream();
  2. Set the transfer authentication information.

    fos.setUsername("xfer");
  3. Set transfer parameters (for example, target rate, destination file name).

    fos.setRateTarget(3000);fos.setDestinationFilePath("/demo/big_trend.mov");
  4. Initiate the session to the remote Aspera Server.

    fos.connect(host);
  5. Loop over the input data and write to the faspstream output stream to transfer.

    fos.write(data, 0, count);
  6. When finished, close the output stream.

    fos.close();

Full Example

 

File to StreamFile to FASP Stream

The FASP Stream SDK can be used to send a byte-stream of data from a file as it is being read by an Aspera Server, this allows the receiving application to access the data in memory as it is being received rather than waiting on the complete file.  The example below shows the normal steps and includes comments explaining the use of the SDK in the C# project.

Java

The general structure of a FASPStream Java application in file to stream mode is as follows:

  1. Create an instance of an input stream using the faspstream.

    public static FaspInputStreamSAE fis = new FaspInputStreamSAE();
  2. Set the transfer authentication information.

    fis.setUsername("asperaweb");fis.setPassword("demoaspera");
  3. Set transfer parameters (for example, target rate, source file name).

    fis.setSourceFilePath(sourceFilePath);
  4. Initiate the session to the remote Aspera Server.

    fis.connect(host);
  5. Loop over the input stream to receive data.

    destFileStream.write(data, 0, count);
  6. When finished, close the input stream.

    fis.close();
    

Full Example

 

C#

The general structure of a FASPStream C# application in file to stream mode is as follows:

  1. Create an instance of an input stream using the faspstream.

    FaspInputStream fis = new FaspInputStream();
  2. Set the transfer authentication information.

    fis.setUsername("xfer");
  3. Set transfer parameters (for example, target rate, source file name).

    fis.setSourceFilePath(sourceFilePath);
  4. Initiate the session to the remote Aspera Server.

    fis.connect(host);
  5. Loop over the input stream to receive data.

    fis.read(data, 0, length);
  6. When finished, close the input stream.

    fis.close();

Full Example

 
Video player

Video

×