Hello,
Anyone could comment possible ways to add a file to dropbox? I’ve tried everything, the dropbox is configured correctly and I achieved file name appearing in the dropbox but it contains no actual file but a file path instead inside it (bytes size when the actual file are close to 1 mb, testing with .pdf file). The code below is full up untill dropbox (as I have sharepoint and S3 below). The issue is probably with “Api” action step, maybe it’s impossible to send actual file from API action, if not then how it’s done in wappler when not using native S3 support?:
{
"name": "upload_dropbox",
"module": "api",
"action": "send",
"options": {
"url": "https://content.dropboxapi.com/2/files/upload",
"method": "POST",
"headers": {
"Authorization": "{{('Bearer ' + get_storage_config.access_token)}}",
"Dropbox-API-Arg": "{{'{\"path\":\"' + generate_storage_path + '\",\"mode\":\"add\",\"autorename\":false}'}}",
"Content-Type": "application/octet-stream"
},
"data": "{{stat_file.path}}",
"dataType": "binary",
"responseType": "json"
}
full code (without sharepoint and S3):
{
"meta": {
"$_POST": [
{
"type": "text",
"name": "company_slug"
},
{
"type": "text",
"name": "document_title"
},
{
"type": "number",
"name": "document_category_list_id"
},
{
"type": "number",
"name": "parent_folder_id"
},
{
"type": "number",
"name": "seat_role_id"
},
{
"type": "number",
"name": "signing_terms_list_id"
},
{
"type": "number",
"name": "reminder_option_list_id"
},
{
"type": "text",
"name": "positions"
},
{
"type": "file",
"name": "document_file",
"sub": [
{
"type": "text",
"name": "name"
},
{
"type": "text",
"name": "type"
},
{
"type": "number",
"name": "size"
},
{
"type": "text",
"name": "error"
}
],
"outputType": "file"
}
\]
},
"exec": {
"steps": [
{
"name": "identity",
"module": "auth",
"action": "identify",
"options": {
"provider": "darbogarantassecurity"
},
"output": true,
"meta": []
},
{
"name": "",
"module": "auth",
"action": "restrict",
"options": {
"provider": "darbogarantassecurity",
"permissions": [
"Employer"
],
"loginUrl": "/login",
"forbiddenUrl": "/login"
}
},
{
"name": "get_company_info",
"module": "dbconnector",
"action": "single",
"options": {
"connection": "darbogarantas",
"sql": {
"type": "SELECT",
"columns": [
{
"table": "company",
"column": "company_id"
}
],
"table": {
"name": "company"
},
"primary": "company_id",
"joins": [],
"wheres": {
"condition": "AND",
"rules": [
{
"id": "company.company_slug",
"field": "company.company_slug",
"type": "string",
"operator": "equal",
"value": "{{$_POST.company_slug}}",
"data": {
"table": "company",
"column": "company_slug",
"type": "text"
},
"operation": "="
}
]
}
}
},
"output": true,
"meta": [
{
"type": "number",
"name": "company_id"
}
],
"outputType": "object"
},
{
"name": "get_storage_config",
"module": "dbconnector",
"action": "single",
"options": {
"connection": "darbogarantas",
"sql": {
"type": "SELECT",
"columns": [
{
"table": "company_storage_config",
"column": "storage_provider"
},
{
"table": "company_storage_config",
"column": "access_token"
},
{
"table": "company_storage_config",
"column": "bucket_name"
},
{
"table": "company_storage_config",
"column": "site_url"
},
{
"table": "company_storage_config",
"column": "drive_id"
}
],
"table": {
"name": "company_storage_config"
},
"primary": "company_storage_config_id",
"joins": [],
"wheres": {
"condition": "AND",
"rules": [
{
"id": "company_storage_config.company_id",
"field": "company_storage_config.company_id",
"type": "double",
"operator": "equal",
"value": "{{get_company_info.company_id}}",
"data": {
"table": "company_storage_config",
"column": "company_id",
"type": "number"
},
"operation": "="
},
{
"id": "company_storage_config.is_active",
"field": "company_storage_config.is_active",
"type": "boolean",
"operator": "equal",
"value": "{{true}}",
"data": {
"table": "company_storage_config",
"column": "is_active",
"type": "boolean"
},
"operation": "="
}
]
}
}
},
"output": true,
"meta": [
{
"type": "text",
"name": "storage_provider"
},
{
"type": "text",
"name": "access_token"
},
{
"type": "text",
"name": "bucket_name"
},
{
"type": "text",
"name": "site_url"
},
{
"type": "text",
"name": "drive_id"
}
],
"outputType": "object"
},
{
"name": "upload_to_temp",
"module": "upload",
"action": "upload",
"options": {
"path": "{{'/temp/company_documents/' + get_company_info.company_id}}",
"fields": "{{$_POST.document_file}}"
},
"output": true,
"meta": [
{
"name": "name",
"type": "text"
},
{
"name": "path",
"type": "text"
},
{
"name": "url",
"type": "text"
},
{
"name": "type",
"type": "text"
},
{
"name": "size",
"type": "number"
},
{
"name": "error",
"type": "number"
}
],
"outputType": "file"
},
{
"name": "validate_file",
"module": "validator",
"action": "validate",
"options": {
"data": [
{
"name": "validate_type",
"value": "{{upload_to_temp.type}}",
"rules": {
"core:pattern": {
"param": "^(application\\/pdf|image\\/.+)$"
}
}
},
{
"name": "validate_size",
"value": "{{upload_to_temp.size}}",
"rules": {
"core:max": {
"param": 52428800
}
}
}
]
}
},
{
"name": "generate_storage_path",
"module": "core",
"action": "setvalue",
"options": {
"value": "{{'/company/' + get_company_info.company_id + '/documents/' + NOW.formatDate('yyyyMMdd_HHmmss') + '_' + upload_to_temp.name}}"
},
"output": true,
"meta": [],
"outputType": "text"
},
{
"name": "",
"module": "core",
"action": "condition",
"options": {
"if": "{{get_storage_config.storage_provider=='dropbox'}}",
"then": {
"steps": [
{
"name": "stat_file",
"module": "fs",
"action": "stat",
"options": {
"path": "{{upload_to_temp.path}}"
},
"output": true,
"outputType": "object",
"meta": [
{
"name": "type",
"type": "text"
},
{
"name": "name",
"type": "text"
},
{
"name": "path",
"type": "text"
},
{
"name": "url",
"type": "text"
},
{
"name": "size",
"type": "number"
},
{
"name": "folder",
"type": "text"
},
{
"name": "basename",
"type": "text"
},
{
"name": "extension",
"type": "text"
},
{
"name": "created",
"type": "date"
},
{
"name": "accessed",
"type": "date"
},
{
"name": "modified",
"type": "date"
}
]
},
{
"name": "upload_dropbox",
"module": "api",
"action": "send",
"options": {
"url": "https://content.dropboxapi.com/2/files/upload",
"method": "POST",
"headers": {
"Authorization": "{{('Bearer ' + get_storage_config.access_token)}}",
"Dropbox-API-Arg": "{{'{\\"path\":\"' + generate_storage_path + '\",\"mode\":\"add\",\"autorename\":false}'}}",
"Content-Type": "application/octet-stream"
},
"data": "{{stat_file.path}}",
"dataType": "binary",
"responseType": "json"
},
"output": true,
"meta": [
{
"name": "id",
"type": "text"
},
{
"name": "name",
"type": "text"
},
{
"name": "path_display",
"type": "text"
},
{
"name": "size",
"type": "number"
}
],
"outputType": "object"
},
{
"name": "cleanup_temp_dropbox",
"module": "fs",
"action": "remove",
"options": {
"path": "{{upload_to_temp.path}}"
},
"outputType": "boolean"
},
{
"name": "insert_document_dropbox",
"module": "dbupdater",
"action": "insert",
"options": {
"connection": "darbogarantas",
"sql": {
"type": "insert",
"values": [
{
"table": "company_documents",
"column": "company_id",
"type": "number",
"value": "{{get_company_info.company_id}}"
},
{
"table": "company_documents",
"column": "document_name",
"type": "text",
"value": "{{upload_to_temp.name}}"
},
{
"table": "company_documents",
"column": "document_title",
"type": "text",
"value": "{{$_POST.document_title}}"
},
{
"table": "company_documents",
"column": "file_path",
"type": "text",
"value": "{{upload_dropbox.path_display || generate_storage_path}}"
},
{
"table": "company_documents",
"column": "file_size",
"type": "number",
"value": "{{upload_to_temp.size}}"
},
{
"table": "company_documents",
"column": "mime_type",
"type": "text",
"value": "{{upload_to_temp.type}}"
},
{
"table": "company_documents",
"column": "storage_provider",
"type": "text",
"value": "dropbox"
},
{
"table": "company_documents",
"column": "storage_path",
"type": "text",
"value": "{{upload_dropbox.path_display || generate_storage_path}}"
},
{
"table": "company_documents",
"column": "storage_file_id",
"type": "text",
"value": "{{upload_dropbox.id || 'id_pending'}}"
},
{
"table": "company_documents",
"column": "parent_folder_id",
"type": "number",
"value": "{{$\_POST.parent_folder_id || null}}"
},
{
"table": "company_documents",
"column": "document_category_list_id",
"type": "number",
"value": "{{$\_POST.document_category_list_id || null}}"
},
{
"table": "company_documents",
"column": "seat_role_id",
"type": "number",
"value": "{{$\_POST.seat_role_id || null}}"
},
{
"table": "company_documents",
"column": "signing_terms_list_id",
"type": "number",
"value": "{{$\_POST.signing_terms_list_id || null}}"
},
{
"table": "company_documents",
"column": "reminder_option_list_id",
"type": "number",
"value": "{{$\_POST.reminder_option_list_id || null}}"
},
{
"table": "company_documents",
"column": "added_by_user_id",
"type": "number",
"value": "{{identity}}"
}
],
"table": "company_documents",
"returning": "company_document_id"
}
},
"output": true,
"meta": [
{
"type": "number",
"name": "company_document_id"
},
{
"name": "affected",
"type": "number"
}
]
}
]
}
},
"outputType": "boolean"
}


