import * as wmill from "windmill-client";
import axios from "axios";
type Nextcloud = {
baseUrl: string,
password: string,
username: string
};
export async function main(
ncResource: Nextcloud,
userId: string | null = null,
path: string,
data: string,
useAppApiAuth: boolean = false,
) {
try {
const res = await axios.request(
{
method: "PUT",
url: `/remote.php/dav/files/${userId || ncResource.username}/${path}`,
baseURL: ncResource.baseUrl,
data,
headers: {
Authorization: `Basic ${
btoa(`${userId || ncResource.username}:${ncResource.password}`)
}`,
},
...(useAppApiAuth && ({
headers: {
"AA-VERSION": "2.3.0",
"EX-APP-ID": "flow",
"EX-APP-VERSION": "1.0.0",
"AUTHORIZATION-APP-API": btoa(
`${userId || ncResource.username}:${ncResource.password}`,
),
},
})),
},
);
return res.data;
} catch (e) {
console.log(e);
console.log(e.response.data);
}
}
Submitted by nextcloud 4 days ago
import * as wmill from "windmill-client@1";
import axios from "axios";
type Nextcloud = {
baseUrl: string,
password: string,
username: string
};
export async function main(
ncResource: Nextcloud,
userId: string | null = null,
path: string,
data: string,
useAppApiAuth: boolean = false,
) {
try {
const res = await axios.request(
{
method: "PUT",
url: `/remote.php/dav/files/${userId || ncResource.username}/${path}`,
baseURL: ncResource.baseUrl,
data,
headers: {
Authorization: `Basic ${
btoa(`${userId || ncResource.username}:${ncResource.password}`)
}`,
},
...(useAppApiAuth && ({
headers: {
"AA-VERSION": "2.3.0",
"EX-APP-ID": "flow",
"EX-APP-VERSION": "1.0.0",
"AUTHORIZATION-APP-API": btoa(
`${userId || ncResource.username}:${ncResource.password}`,
),
},
})),
},
);
return res.data;
} catch (e) {
console.log(e);
console.log(e.response.data);
}
}
Submitted by nextcloud 4 days ago
import * as wmill from "windmill-client@1";
import axios from "axios";
type Nextcloud = {
baseUrl: string,
password: string,
username: string
};
export async function main(
ncResource: Nextcloud,
userId: string | null = null,
path: string,
data: string,
useAppApiAuth: boolean = false,
) {
try {
const res = await axios.request(
{
method: "PUT",
url: `/remote.php/dav/files/${userId || ncResource.username}/${path}`,
baseURL: ncResource.baseUrl,
data,
headers: {
Authorization: `Basic ${
btoa(`${userId || ncResource.username}:${ncResource.password}`)
}`,
},
...(useAppApiAuth && ({
headers: {
"AA-VERSION": "2.3.0",
"EX-APP-ID": "flow",
"EX-APP-VERSION": "1.0.0",
"AUTHORIZATION-APP-API": btoa(
`${userId || ncResource.username}:${ncResource.password}`,
),
},
})),
},
);
return res.data;
} catch (e) {
console.log(e);
console.log(e.response.data);
}
}
Submitted by nextcloud 5 days ago
import * as wmill from "windmill-client@1";
import axios from "axios";
// fill the type, or use the +Resource type to get a type-safe reference to a resource
// type Postgresql = object
export async function main(
ncResource: Nextcloud,
userId: string | null = null,
path: string,
data: string,
useAppApiAuth: boolean = false,
) {
try {
const res = await axios.request(
{
method: "PUT",
url: `/remote.php/dav/files/${userId || ncResource.username}/${path}`,
baseURL: ncResource.baseUrl,
data,
headers: {
Authorization: `Basic ${
btoa(`${userId || ncResource.username}:${ncResource.password}`)
}`,
},
...(useAppApiAuth && ({
headers: {
"AA-VERSION": "2.3.0",
"EX-APP-ID": "flow",
"EX-APP-VERSION": "1.0.0",
"AUTHORIZATION-APP-API": btoa(
`${userId || ncResource.username}:${ncResource.password}`,
),
},
})),
},
);
return res.data;
} catch (e) {
console.log(e);
console.log(e.response.data);
}
}
Submitted by nextcloud 6 days ago
import * as wmill from "windmill-client@1";
import axios from "axios";
// fill the type, or use the +Resource type to get a type-safe reference to a resource
// type Postgresql = object
export async function main(
nextcloudResource: string,
userId: string | null = null,
path: string,
data: string,
useAppApiAuth: boolean = false,
) {
const ncResource = await wmill.getResource(
nextcloudResource,
);
try {
const res = await axios.request(
{
method: "PUT",
url: `/remote.php/dav/files/${userId || ncResource.username}/${path}`,
baseURL: ncResource.baseUrl,
data,
headers: {
Authorization: `Basic ${
btoa(`${userId || ncResource.username}:${ncResource.password}`)
}`,
},
...(useAppApiAuth && ({
headers: {
"AA-VERSION": "2.3.0",
"EX-APP-ID": "flow",
"EX-APP-VERSION": "1.0.0",
"AUTHORIZATION-APP-API": btoa(
`${userId || ncResource.username}:${ncResource.password}`,
),
},
})),
},
);
return res.data;
} catch (e) {
console.log(e);
console.log(e.response.data);
}
}
Submitted by nextcloud 10 days ago