Like any other of our modules, the CloudFile module provide a easy to use Interface.
So you are able to use the module within your own extensions without any major work.

I will guide you step by step to provide Cloud Storage functions:

 

1. You need to get a list of available Connections

[prism field=source1 language=php]

This will return an array of configured connections, in the following format:

[prism field=return1]

Use this list select connection ID you want to use.

2. Use the Connection

This is the important step, but is not much harder, then the first one.

You only need to understand the two systems:
There are hierarchical and ID based systems.

  1. Hierarchical file systems will with “real” file path, directories, subdirectories, …. Examples are FTP, Dropbox, Filesystem
  2. ID based systems, which use filepaths only to organize visual presentation, but works only with IDs. Every directory and file have a unique ID. A major example is Google Drive.

Because the CloudFile module supports both types, you will get a path and a key everytime you work with files and directories. Use both to be fully compatible to both systems.

2.1 Get Connection Object

[prism field=source2 language=php]

That’s all!

Now you have a object from your Adapter, which inherits from CloudFileAdapterBase, and could work with the cloud storage.

Found all available methods here: https://redoonetworks.github.io/VtigerCRM-CloudFile-Developers/output/classes/CloudFile.Adapter.Base.html

Examples

Create a folder:

[prism field=source3 language=php]

Upload a file:

[prism field=source4 language=php]

This uploads the file from $localFilename into the current folder and same filename of the local file.