ioBroker.js-controller icon indicating copy to clipboard operation
ioBroker.js-controller copied to clipboard

[enhancement]: common path format for iobroker file resources

Open klein0r opened this issue 2 months ago • 3 comments

No existing issues.

  • [X] There is no existing issue for my request.

Description

Let's say I want to pass a file path to another adapter (e.g. with sendTo). What's the best way to describe a ressource-path (meta id + filepath). This could be useful to tell telegram or pushover to send an image. Or attach a file to an email (via Blockly).

Example: 0_userdata.0 is the id of the meta object and a file the file camera/backyard.jpg has been updated (e.g. with the new httpGet blocks + writeFile. How should we extend the other adapters to give them a resource name (id + path).

Why?

To implement a common way in other adapters for file handling.

How?

Maybe via an object?

{
  id: '0_userdata.0`,
  filepath: 'camera/backyard.jpg',
}

or as a resource string? e.g.

iofile://0_userdata.0/camera/backyard.jpg

or as urn (RFC 2141)? e.g.

urn:iofile:0_userdata.0:camera/backyard.jpg

In that case a parser of those string would be helpful (adapter utils?). The cli uses the first part as the id. But we have to ensure that this is not "normal text" and follows a specific pattern.

iobroker file write ~/cam.jpg 0_userdata.0/camera/backyard.jpg

Maybe we should also extend readFile (and writeFile?) to also accept those resource identifiers.

klein0r avatar Apr 30 '24 13:04 klein0r