It is recommended for better support of types by code assistance in IDEs to usegetFrappeStorageController()
in order to get the instance of FrappeStorageController
instead of renovation.storage
which is StorageController
if the backend is Frappè, for instance. In this guide we will use Frappé as an example and use getFrappeStorageController()
To upload file to the backend using Socket IO
FrappeUploadFileParams
property | type | required | description |
file | dynamic | yes | File to upload to the backend |
fileName | String | yes | File name |
isPrivate | bool | no | Whenever the file is private or not |
BehaviorSubject<FrappeUploadStatus>
getFrappeStorageController().uploadFile(FrappeUploadFileParams(file: File(image.path), fileName: imageName)).stream.map((s){print(s.status);});
To upload file to the backend using http protocol
FrappeUploadFileParams
property | type | required | description |
file | dynamic | yes | File to upload to the backend |
fileName | String | yes | File name |
isPrivate | bool | no | Whenever the file is private or not |
FrappeUploadFileResponse
RequestResponse<FrappeUploadFileResponse> response = await getFrappeStorageController().uploadViaHTTP(FrappeUploadFileParams(file: File(image.path),fileName: imageName));if(response.isSuccess){print("File url : ${response.data.fileUrl}");}else{print(response.error);}
To check if given folder name exits on the backend
property | type | required | description |
folderDir | String | yes | Folder path to be checked |
RequestResponse<bool>
RequestResponse<bool> response = await getFrappeStorageController().checkFolderExists("/path/to/dir");if(response.isSuccess){print("Folder exists");}else{print(response.error);}
To check if given folder name exits on the backend
property | type | required | description |
folderName | String | yes | Folder name |
parentFolder | String | no | Parent folder to create the folder ,default = "Home" |
RequestResponse<bool>
RequestResponse<bool> response = await getFrappeStorageController().createFolder("folderName");if(response.isSuccess){print("Folder created");}else{print(response.error);}
HTTP code:
412
type:
DataFormatError
cause: Folder name forward with slash
suggestion: remove the slash from folder name