Copying between files

File copying can be used to:


Decompress example.csv.gz into example.csv:

source = IOStreams.path("example.csv.gz")

Decrypt a file encrypted with Symmetric Encryption:

source = IOStreams.path("example.csv.enc")

Encrypt a file using PGP encryption so that it can only be read by

source = IOStreams.path("example.csv")
target = IOStreams.path("example.csv.pgp")
target.option(:pgp, recipient: "")

When the file name does not have file extensions that would allow IOStreams to infer what streams to apply, the streams can be explicitly set using stream.

In this example, the file CUSTOMER_DATA

Decrypt the contents of file that was encrypted with Symmetric Encryption PGP encrypt the output file and write it to xyz.csv.pgp using the pgp key that was imported for

input = IOStreams.path("CUSTOMER_DATA").stream(:enc)
IOStreams.path("xyz.csv.pgp").option(:pgp, recipient: "").copy_from(input)

To copy a file without performing any conversions (ignore file extensions), set convert to false:

input = IOStreams.path("")
IOStreams.path("sample.copy").copy_from(input, convert: false)