Test Enterprise-Class Web CMS Scrivito Free for 30 Days
Test Scrivito Free for 30 Days

copy(options)

Prepares the Binary instance for copying. Returns a FutureBinary.

Note: This does not perform the actual copying. The actual copying can be triggered by putting the returned 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, with a new filename.

sourceImage = Scrivito.getClass("Image").all().first();
targetImage = Scrivito.getClass("Image").create({ });
betterName = "better-than-the-old-one." + sourceImage.contentType();
futureBinary = sourceImage.get("blob").copy({ filename: betterName });
futureBinary.into(sourceImage).then(copiedBinary => sourceImage.update({ blob: copiedBinary }));