toFile

toFile

Overview

The toFile function takes any content and creates a file object.

Note:

  • It is advisable to use file objects from the cloud directly and only in the absence of such means should this task be used.
  • The toFile task is not a utility to create files of desired type. It only helps wrapping up contents inside a file object. So there shall be instances where the file might appear broken or corrupted unless appropriate content is supplied during file creation.
  • The file object would be created in the name of the file along with the extension(if provided).

Return Type

  • FILE

Syntax

<variable>=<value>.toFile(<file_name>);

where,

ParameterData typeDescription
<variable>BOOLEANVariable which will contain the created file object.
<value>TEXT/COLLECTION

The value that needs to be converted to a file object.

Note: In Zoho Creator, the input value cannot be more than 50 MB.
<file_name>TEXT

The value which will represent the file name and its extension.

Example

Imagine that you need to upload a CSV file to workdrive under a particular folder. The toFile function can convert the csv content to a file with a specified name and extension.

 csv_file="\"Name\",\"Age\"\n\"Mathew\",\"20\"".tofile("sample.csv");
 zoho.workdrive.uploadFile(csv_file,"g5lg8678dc59b6c10007586b847fc1904c904","sample.csv",true,"work_drive_conn");// This would create a file in workdrive with the name sample.csv

Related Links

Share this post : FacebookTwitter

Still can't find what you're looking for?

Write to us: support@zohodeluge.com