Renovation
Search…
.storage

Things to know

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()

.uploadFile()

To upload file to the backend using Socket IO

Input

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

Output

BehaviorSubject<FrappeUploadStatus>

Example

1
getFrappeStorageController().uploadFile(FrappeUploadFileParams(
2
file: File(image.path), fileName: imageName)).stream.map((s){
3
print(s.status);
4
});
Copied!

.uploadViaHTTP() ☆

To upload file to the backend using http protocol

Input

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

Output

FrappeUploadFileResponse

Example

1
RequestResponse<FrappeUploadFileResponse> response = await getFrappeStorageController().uploadViaHTTP(
2
FrappeUploadFileParams(
3
file: File(image.path),
4
fileName: imageName
5
)
6
);
7
8
if(response.isSuccess){
9
print("File url : ${response.data.fileUrl}");
10
}else{
11
print(response.error);
12
}
Copied!

.checkFolderExists()

To check if given folder name exits on the backend

Input

property
type
required
description
folderDir
String
yes
Folder path to be checked

Output

RequestResponse<bool>

Example

1
RequestResponse<bool> response = await getFrappeStorageController().checkFolderExists(
2
"/path/to/dir"
3
);
4
5
if(response.isSuccess){
6
print("Folder exists");
7
}else{
8
print(response.error);
9
}
Copied!

.createFolder()

To check if given folder name exits on the backend

Input

property
type
required
description
folderName
String
yes
Folder name
parentFolder
String
no
Parent folder to create the folder ,default = "Home"

Output

RequestResponse<bool>

Example

1
RequestResponse<bool> response = await getFrappeStorageController().createFolder(
2
"folderName"
3
);
4
5
if(response.isSuccess){
6
print("Folder created");
7
}else{
8
print(response.error);
9
}
Copied!

Possible Errors

Wring input

HTTP code: 412
type: DataFormatError
cause: Folder name forward with slash
suggestion: remove the slash from folder name
Last modified 1yr ago