.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

getFrappeStorageController().uploadFile(FrappeUploadFileParams(
file: File(image.path), fileName: imageName)).stream.map((s){
print(s.status);
});

.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

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);
}

.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

RequestResponse<bool> response = await getFrappeStorageController().checkFolderExists(
"/path/to/dir"
);
if(response.isSuccess){
print("Folder exists");
}else{
print(response.error);
}

.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

RequestResponse<bool> response = await getFrappeStorageController().createFolder(
"folderName"
);
if(response.isSuccess){
print("Folder created");
}else{
print(response.error);
}

Possible Errors

Wring input

HTTP code: 412

type: DataFormatError

cause: Folder name forward with slash

suggestion: remove the slash from folder name