[RELEASE] File Manager Device

v0.2.3 Adds the ability to read and upload image files

2 Likes

Can your driver create folders so the root is not too messy?

Doesn’t appear to be supported..

In RM, how do i access the file contents?
Driver page works great.
How do I get it into a string to manipulate with RM?

It should place the return of a read into the attribute fileContent, which should be available under the Custom Attributes.

Where am I going wrong?

I change the contents of the file, RM shows null.
Device works in device tab.

I thought I had it!

Did you do a readFile to load the attribute? (It clears the attribute after 30 seconds BTW.)

Added a line, readfile, same result.

1 Like

Not sure why RM doesn’t like it but


RM has it’s own read/write/append such that the first action should yield the same result as the what should occur by combining actions 2 & 3 (which don’t seem to load the variable even if you introduce a delay)

Found the issue, on line 47 change

attribute "fileContents", "string"

to

attribute "fileContent", "string"
2 Likes

Bingo!
Thanks for this driver, it has great potential.
Off to experiment with it.

2 Likes

Getting unexpected responded, and error.


writeFile() needs 2 parameters, the file name and the text to write; doesn’t appear that the rule is furnishing either.

Got that, thanks!

Another question...

How do I capture the result of "fileExists (XXX)?

A question, of many, mostly RM syntax for the device.

Thanks for the help, and the driver!

Pull down the latest version and you’ll have an attribute called exist

Discrepancy between passed variable name (fName) and Json variable name (fname) is causing the deleteFile() not to work. Thanks:

String deleteFile(fName){
bodyText = JsonOutput.toJson(name:"$fname",type:"file")
params = [
uri: "http://127.0.0.1:8080",
path: "/hub/fileManager/delete",
contentType:"text/plain",
requestContentType:"application/json",
body: bodyText
]
httpPost(params) { resp ->
return resp.data.toString()
}
}

Hate it when I do that. Fixed.

2 Likes

Can I use webcore to delete a local file or do I have to use RM?

Conversation on this thread did remind me that I had been thinking it would be nice if files could be backed up alongside the platform backup. I could be repeating earlier conversations, so please point me to those if necessary.... but a "backup all files" command could be nice.... Haven't thought it through I will admit.... A tar or at least archive file on the receiving end would be nice.... so may need more than a driver change.... but some buy-in would be nice....

Should be able to delete from webCoRE by adding the filename in as parameter 1 and using the deleteFile command in the driver.