copy(options)

Prepares the Binary instance for copying.

Note: This does not perform the actual copying but returns a FutureBinary. The actual copying can be triggered by putting the FutureBinary into an Obj.

Params

  • options (optional) (Object) - Options to pass when copying a Binary:
    • filename (String) - The new file name.
    • contentType (String) - A content type for overriding the original contentType.

Throws

  • ArgumentError - If any of the passed-in options are blank.

Returns

FutureBinary

Example

Create a copy of a random image. This involves three steps, creating the new image object, copying the blob of the source image, and placing this copy into the new object.

Copy
i = Scrivito.getClass("Image").create({ })
blob = Scrivito.getClass("Image").all().first().get("blob")
futureBinary = blob.copy()
futureBinary.into(i).then(copiedBinary => i.update({ blob: copiedBinary }))