Uploading Files

The fileCreate API call is used to upload files into your company's root folder. It will also create any missing folders that you may refer to in the "path" parameter (see below) .

This is only possible if the user has approved your access.
(see Listing Accounts and Account Details)

JSON request

Parameters:
uid: the unique reference used when creating the account.
notify: [optional] If set to 'true', the customer will get an notification email.

The following 3 parameters are [optional] and define where the file should go relative to the root folder. If more than 1 of the parameters is defined, "path" takes precedence, then "folder_id" and finally "matter_id". If all 3 are missing or empty, the file is stored directly in the root folder.

path: In the form "/this/that/the other"
folder_id: Returned when calling New HouseMove.
matter_id: The fileID you used when calling New HouseMove.

filename: What the file should be called.
Name clashes are not treated as errors, instead, they are resolved by renaming the file adding " - Copy ([date & Time])". i.e

sample1.png would become
sample1 - Copy (1 May 2022 16:31).png

content: the actual file content as a base64 data URL. i.e.

data:[mime-type];base64,[base64 encoded file]

{
  "action": "fileCreate",
  "uid": 1001,
  "path": "/images/sample1.png",
  "content": "data:image/png;base64,iVBORw0KGgoAA...RU5ErkJggg=="
}

JSON response

Success:

{
  "error": "",
  "status": "success",
  "data": "-- Base64 encoded AES-256-CBC encrypted JSON --",
  "action": "fileCreate",
  "version": "1.07",
  "proc_time": 1651419658,
  "proc_id": 77
}

"data" (decrypted)
{
    "squid_id":63
}

Failure:

{
  "error": "mime-type not recognised",
  "status": "failure",
  "data": "-- Base64 encoded AES-256-CBC encrypted JSON --",
  "action": "fileCreate",
  "version": "1.07",
  "proc_time": 1651425411,
  "proc_id": 79
}

"data" (decrypted)
{
  "mime-type": "foo/bar"
}

Decrypted Data Fields

squid_id: SquidVault's internal unique ID for this file. This should be stored so that you can refer to the file at a later date as the customer can rename the file at any time.

Common errors

no uid: uid missing

invalid uid: account uid unauthorised or invalid

not approved: The the user hasn't approved your access.

no filename: filename empty or missing

no content: content empty or missing

mime-type not recognised: bad or missing mime-type

root folder missing: company root folder not found

invalid filename: names can't contain \ : * ? " < > or |

file size limit exceeded: file too big

storage limit exceeded: no more space available

bad metas: metaTags corrupt or not an array

Test Files

We have provided a set of sample files for you to use at the following address: https://Squidvault.com/testfiles/

i.e. https://Squidvault.com/testfiles/sample3.docx

Older Word Files
metaTag: application/msword

sample1.doc

Newer Word Files
metaTag: application/vnd.openxmlformats-officedocument.wordprocessingml.document

sample2.docx
sample3.docx

Newer Excel Files
metaTag: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

sample1.xlsx
sample2.xlsx
sample3.xlsx

JPEG Images
metaTag: image/jpeg

sample1.jpg
sample2.jpg
sample3.jpg

PNG Images
metaTag: image/png

sample1.png
sample2.png
sample3.png

PDF Files
metaTag: application/pdf

sample1.pdf
sample2.pdf
sample3.pdf

<?php
	print_r(request([
		'action'=>'fileCreate',  
		'uid'=>1001,
		'path'=>'/images',
		#'folder_id'=>'279',
		#'matter_id'=>'357922',
		'filename'=>'sample1.png',
		'content'=>'data:image/png;base64,'.
			base64_encode(
				file_get_contents('https://Squidvault.com/testfiles/sample1.png')
			)
	]));

    /*############### OUTPUT ##################
	
	Array(
        [error] => 
        [status] => success
        [data] => {"squid_id":63}
        [action] => fileCreate
        [version] => 1.07
        [proc_time] => 1651419658
        [proc_id] => 77
    )

    #########################################*/

?>
Copy Code