From 0a1ab3d68583b24f9588f376c62416d864b3f87e Mon Sep 17 00:00:00 2001 From: CalDescent Date: Fri, 28 Apr 2023 10:57:04 +0100 Subject: [PATCH] Added GET_QDN_RESOURCE_METADATA action. --- Q-Apps.md | 15 +++++++++++++-- .../qortal/api/resource/ArbitraryResource.java | 9 +++------ src/main/resources/q-apps/q-apps.js | 5 +++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Q-Apps.md b/Q-Apps.md index 77095c72..0f5bc7e8 100644 --- a/Q-Apps.md +++ b/Q-Apps.md @@ -240,6 +240,9 @@ Here is a list of currently supported actions: - SEARCH_QDN_RESOURCES - GET_QDN_RESOURCE_STATUS - GET_QDN_RESOURCE_PROPERTIES +- GET_QDN_RESOURCE_METADATA +- GET_QDN_RESOURCE_URL +- LINK_TO_QDN_RESOURCE - FETCH_QDN_RESOURCE - PUBLISH_QDN_RESOURCE - PUBLISH_MULTIPLE_QDN_RESOURCES @@ -258,8 +261,6 @@ Here is a list of currently supported actions: - FETCH_BLOCK_RANGE - SEARCH_TRANSACTIONS - GET_PRICE -- GET_QDN_RESOURCE_URL -- LINK_TO_QDN_RESOURCE - GET_LIST_ITEMS - ADD_LIST_ITEMS - DELETE_LIST_ITEM @@ -420,6 +421,16 @@ let res = await qortalRequest({ // Returns: filename, size, mimeType (where available) ``` +### Get QDN resource metadata +``` +let res = await qortalRequest({ + action: "GET_QDN_RESOURCE_METADATA", + name: "QortalDemo", + service: "THUMBNAIL", + identifier: "qortal_avatar" // Optional +}); +``` + ### Publish a single file to QDN _Requires user approval_.
Note: this publishes a single, base64-encoded file. Multi-file resource publishing (such as a WEBSITE or GIF_REPOSITORY) is not yet supported via a Q-App. It will be added in a future update. diff --git a/src/main/java/org/qortal/api/resource/ArbitraryResource.java b/src/main/java/org/qortal/api/resource/ArbitraryResource.java index 64ee2a6f..dddad594 100644 --- a/src/main/java/org/qortal/api/resource/ArbitraryResource.java +++ b/src/main/java/org/qortal/api/resource/ArbitraryResource.java @@ -721,12 +721,9 @@ public class ArbitraryResource { } ) @SecurityRequirement(name = "apiKey") - public ArbitraryResourceMetadata getMetadata(@HeaderParam(Security.API_KEY_HEADER) String apiKey, - @PathParam("service") Service service, - @PathParam("name") String name, - @PathParam("identifier") String identifier) { - Security.checkApiCallAllowed(request); - + public ArbitraryResourceMetadata getMetadata(@PathParam("service") Service service, + @PathParam("name") String name, + @PathParam("identifier") String identifier) { ArbitraryDataResource resource = new ArbitraryDataResource(name, ResourceIdType.NAME, service, identifier); try { diff --git a/src/main/resources/q-apps/q-apps.js b/src/main/resources/q-apps/q-apps.js index 9ae4e478..9da494c0 100644 --- a/src/main/resources/q-apps/q-apps.js +++ b/src/main/resources/q-apps/q-apps.js @@ -250,6 +250,11 @@ window.addEventListener("message", (event) => { url = "/arbitrary/resource/properties/" + data.service + "/" + data.name + "/" + identifier; return httpGetAsyncWithEvent(event, url); + case "GET_QDN_RESOURCE_METADATA": + identifier = (data.identifier != null) ? data.identifier : "default"; + url = "/arbitrary/metadata/" + data.service + "/" + data.name + "/" + identifier; + return httpGetAsyncWithEvent(event, url); + case "SEARCH_CHAT_MESSAGES": url = "/chat/messages?"; if (data.before != null) url = url.concat("&before=" + data.before);