Doc: Updated doc for resource creation from a plugin

pull/4436/head
Laurent Cozic 2021-01-27 13:00:10 +00:00
parent ea49242f24
commit 35597ce3c2
1 changed files with 14 additions and 0 deletions

View File

@ -312,6 +312,20 @@ async function fetchAllNotes() {
lines.push('');
lines.push('The "data" field is required, while the "props" one is not. If not specified, default values will be used.');
lines.push('');
lines.push('**From a plugin** the syntax to create a resource is also a bit special:');
lines.push('');
lines.push('```javascript');
lines.push('\tawait joplin.data.post(');
lines.push('\t\t["resources"],');
lines.push('\t\tnull,');
lines.push('\t\t{ title: "test.jpg" }, // Resource metadata');
lines.push('\t\t[');
lines.push('\t\t\t{');
lines.push('\t\t\t\tpath: "/path/to/test.jpg", // Actual file');
lines.push('\t\t\t},');
lines.push('\t\t]');
lines.push('\t);');
lines.push('```');
}
if (model.type === BaseModel.TYPE_TAG) {