Skip to content
Snippets Groups Projects
Commit 546703fe authored by Alexey Lunin's avatar Alexey Lunin
Browse files

Added manual create and put methods

parent a172c3b8
No related branches found
No related tags found
1 merge request!25Ability to upload a document in Dashboard
...@@ -897,6 +897,49 @@ const connection = Penpal.connectToParent({ ...@@ -897,6 +897,49 @@ const connection = Penpal.connectToParent({
return encodeResponse("200", response.data, "Email signed"); return encodeResponse("200", response.data, "Email signed");
}, },
createDocument: async (path, passportUUID, contenttype) => {
const authenticationPublicKey = localStorage.getItem("authenticatedIdentity");
if (
!authenticationPublicKey ||
!window.loadedIdentities[authenticationPublicKey] ||
!extendPinCodeTtl(authenticationPublicKey)
) {
return encodeResponse("400", "", "Identity not authenticated");
}
const headers = window.viamApi.getConfig().headers;
headers.path = path;
headers.passportuuid = passportUUID;
headers.contenttype = contenttype;
const response = await executeRestfulFunction(
"private", window.viamApi, window.viamApi.documentCreateDocument);
return encodeResponse("200", response.data, "Document created");
},
putDocument: async (passportUUID, resourceid, file) => {
const authenticationPublicKey = localStorage.getItem("authenticatedIdentity");
if (
!authenticationPublicKey ||
!window.loadedIdentities[authenticationPublicKey] ||
!extendPinCodeTtl(authenticationPublicKey)
) {
return encodeResponse("400", "", "Identity not authenticated");
}
const data = new FormData();
data.append('file', file);
const config = window.viamApi.getConfig();
config.headers.passportuuid = passportUUID;
config.headers.resourceid = resourceid;
config.data = data;
const response = await executeRestfulFunction(
"private", window.viamApi, window.viamApi.documentCreateDocument);
return encodeResponse("200", response.data, "Document created");
},
hasSession() { hasSession() {
return new Penpal.Promise(result => { return new Penpal.Promise(result => {
const authenticationPublicKey = localStorage.getItem("authenticatedIdentity"); const authenticationPublicKey = localStorage.getItem("authenticatedIdentity");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment