|
This macro is used to download the files stored in the Storage services available in Scriptcase, they are: Google Drive, DropBox and Amazon S3.
First of all, it is necessary to create the keys to use these APIs, either for use with the macro or through the tool interface.
See below for how to obtain the credentials for each of them.
Parameters
| Parameters |
Value |
Description |
profile |
Example of how the parameter should be informed.
'profile' => 'profile_name',
This parameter accepts only the name of the profile created.
Click here, to see how to create a profile.
|
We must inform the name of the profile creating in the APIs option in the Tools menu.
When used, this parameter loads the settings informed when the profile is created.
When used, the settings parameter does not need to be informed.
For more details see Using the macro with profile
|
settings |
Example of how the parameter should be informed.
'settings' => [ 'app_name' => 'scriptcase', 'gateway' => 'dropbox', 'api_key' => '', 'api_secret' => '', 'access_token' => '', ],
Note: For more information about the parameter, see the exclusive settings table below, for each of the APIs
|
It receives an array with the access credentials for the API that will be used.
When used, the profile parameter does not need to be entered.
|
file |
Example of how the parameter should be informed.
'file' => {image_file_name},
Allowed options:
- {image_file_name}
- [global_variable]
- ‘File path’
|
This parameter receives the full path until the file is located.
When using a field, it must be the upload nome do file type.
|
destination |
Example of how the parameter should be informed.
Using a field
'parents' => {field_name},
Informando uma String
'parents' => ‘folder_name’,
Allowed options:
- {field_name}
- [global_variable]
- ‘Folder name or local cloud storage path’
|
Directory where the file will be stored
When not informed, the file will be stored at the root of the storage server.
|
Using the macro with profile
The use of the macro with a profile requires the prior creation of the same.
Click here to see how to create a profile on each of the available storage APIs.
The profile contains the data to use the desired API, thus, when using a profile in the macro, it is not necessary to use the settings parameter.
The profile parameter accepts only the name of the profile created, for the dynamic use of the macro, it will be necessary to use the settings parameters.
Example of using the macro with the profile.
sc_api_download([ 'profile' => 'myApi', 'file' => {file}, 'destination' => {destination}, ]);
Using the macro with settings parameter
The array with the access credentials that must be passed in the settings parameter varies according to the API used.
See below how to use this parameter according to each of the available APIs.
When using the settings parameter in the configuration in the macro, it is not necessary to inform a profile.
Using The Macro With Settings - Google Drive API
First, we must have the credentials for using the Google Drive API in hand, click here to learn how to obtain them.
After configuring the credentials, see below all the values of the array that must be passed in the settings parameter using the Google Drive API.
All values below are mandatory when using the settings parameter
| Index |
Value |
Description |
app_name |
Example of how the parameter should be informed.
'app_name' => 'scriptcase',
This index accepts only string
|
App name entered when creating access credentials.
|
gateway |
Example of how the parameter should be informed.
'gateway' => 'google_driver',
This index accepts only string
|
Gateway name to identify the API used.
|
json_oauth |
Example of how the parameter should be informed.
'json_oauth' => 'JSON_code',
Allowed options:
- ‘string’
- {field_name}
- $variable
|
Receives the contents of the user generated authentication (JSON) file.
This file must be downloaded after creating the credentials on the google website.
|
auth_code |
Example of how the parameter should be informed.
'auth_code' => '5/4wHt7TBTY4MtvQ',
Allowed options:
|
Receives the auth_code code, generated after configuring the API following the steps described in the tutorial
How to generate the auth_code for using the Google Driver API
|
token_code |
Example of how the parameter should be informed.
'token_code' => '4/4wHt7TBTY4MtvQ',
Allowed options:
- ‘string’
- {field_name}
- $variable
|
It is possible to generate the token_code using our sc_api_gc_get_obj macro |
Examples when using the macro in Google Drive implementing the parameter settings
sc_api_download([ 'settings' => [ 'app_name' => {appname}, 'gateway' => 'google_drive', 'json_oauth' => {jsonoauth}, 'auth_code' => {authcode}, 'token_code' => {tokencode}, ], 'file' => {files}, 'destination' => {destination}, ]);
Using A Macro With Settings - Dropbox
First, we must have the credentials for using the Google Drive API in hand, click here to learn how to obtain them.
After configuring the credentials, see below all the values of the array that must be passed in the settings parameter using the Dropbox API.
All values below are mandatory when using the settings parameter
| Index |
Value |
Description |
app_name |
Example of how the parameter should be informed.
'app_name' => 'scriptcase',
This index accepts only string
|
App name entered when creating access credentials.
|
gateway |
Exemplo de como o parâmetro deve ser informado.
'gateway' => 'google_driver',
This index accepts only string
|
Gateway name to identify the API used.
|
api_key |
Example of how the parameter should be informed.
'api_key’ => {field_name},
Allowed options:
- ‘string’
- {field_name}
- $variable
|
Receives the app key, generated after configuring the API.
|
api_secret |
Example of how the parameter should be informed.
'api_secret’ => {field_name},
Allowed options:
- ‘string’
- {field_name}
- $variable
|
Receives the app secret, generated after configuring the API.
|
Examples when using the macro in Dropbox implementing the parameter settings
sc_api_download([ 'settings' => [ 'gateway' => 'dropbox', 'api_key' => {apikey}, 'api_secret' => {apisecret}, 'access_token' => {accesstoken}, ], 'file' => {file}, 'destination' => {destination}, ]);
Using The Macro With Settings - Amazon S3
First, we must have the credentials for using the Amazon S3 STORAGE API in hand, click here to learn how to obtain them.
After configuring the credentials, see below all the values of the array that must be passed in the settings parameter using the Amazon S3 API.
All values below are mandatory when using the settings parameter]
| Index |
Value |
Description |
app_name |
Example of how the parameter should be informed.
'app_name' => 'scriptcase',
This index accepts only string
|
App name entered when creating access credentials.
|
gateway |
Example of how the parameter should be informed.
'gateway' => 'google_driver',
This index accepts only string
|
Gateway name to identify the API used.
|
api_key |
Example of how the parameter should be informed.
'api_key’ => {nome_campo},
Allowed options:
- ‘string’
- {field_name}
- $variable
|
Receives the api key, generated after configuring the API.
|
api_secret |
Example of how the parameter should be informed.
'api_secret’ => {nome_campo},
Allowed options:
- ‘string’
- {field_name}
- $variable
|
Receives the api secret, generated after configuring the API.
|
region |
Example of how the parameter should be informed.
'region' => 'us-east-1',
The region parameter of the macro accepts only the region code.
To make it easier, follow a link to check the code for each region.
https://docs.aws.amazon.com/general/latest/gr/rande.html
|
Receives the region code, the same used in the creation of credentials.
|
bucket |
Example of how the parameter should be informed.
'bucket' => 'bucket_name',
Allowed options:
- ‘string’
- {field_name}
- $variable
|
Receives the Bucket Name, generated after configuring the API.
|
Examples when using the macro in Amazon S3 implementing the parameter settings
sc_api_download([ 'settings' => [ 'app_name' => 'scriptcase', 'gateway' => 'S3', 'api_key' => {apikey}, 'api_secret' => {apisecret}, 'region' => {api_region}, 'bucket' => {api_bucket}, ], 'file' => {file}, 'destination' => {destination}, ]);
|