upload: Add support for removing built-in presets
All checks were successful
continuous-integration/appveyor/branch AppVeyor build succeeded

This commit is contained in:
Jonatan Nilsson 2022-10-14 22:47:12 +00:00
parent fda0b7e498
commit 9b227ead62
2 changed files with 20 additions and 16 deletions

View file

@ -130,6 +130,10 @@ export default class Client {
return str; return str;
} }
get(url) {
return this.customRequest('GET', url, null)
}
post(url, body) { post(url, body) {
let parsed = JSON.stringify(body) let parsed = JSON.stringify(body)
return this.customRequest('POST', url, parsed, { return this.customRequest('POST', url, parsed, {

View file

@ -9,9 +9,9 @@ export function uploadMedia(file) {
let out = { let out = {
sizes: { sizes: {
small: {}, small: media.small ? {} : null,
medium: {}, medium: media.medium ? {} : null,
large: {}, large: media.large ? {} : null,
} }
} }
@ -20,33 +20,33 @@ export function uploadMedia(file) {
filename: file.name, filename: file.name,
} }, 'POST', { } }, 'POST', {
preview: media.preview, preview: media.preview,
small: media.small.avif, small: media.small?.avif,
medium: media.medium.avif, medium: media.medium?.avif,
large: media.large.avif, large: media.large?.avif,
/* /*
small: media.small.jpeg, small: media.small.jpeg,
medium: media.medium.avif, medium: media.medium.avif,
large_jpeg: media.large.jpeg,*/ large_jpeg: mediakl.large.jpeg,*/
}).then(res => { }).then(res => {
out.filename = res.filename out.filename = res.filename
out.path = res.path out.path = res.path
out.preview = res.preview out.preview = res.preview
out.sizes.small.avif = res.small if (out.sizes.small) { out.sizes.small.avif = res.small }
out.sizes.medium.avif = res.medium if (out.sizes.medium) { out.sizes.medium.avif = res.medium }
out.sizes.large.avif = res.large if (out.sizes.large) { out.sizes.large.avif = res.large }
out.size = file.size out.size = file.size
out.type = file.type out.type = file.type
return client.post(media.path + '/' + out.filename + '?token=' + token, { return client.post(media.path + '/' + out.filename + '?token=' + token, {
small: media.small.jpeg, small: media.small?.jpeg,
medium: media.medium.jpeg, medium: media.medium?.jpeg,
large: media.large.jpeg, large: media.large?.jpeg,
}) })
.then(res => { .then(res => {
out.sizes.small.jpeg = res.small if (out.sizes.small) { out.sizes.small.jpeg = res.small }
out.sizes.medium.jpeg = res.medium if (out.sizes.medium) { out.sizes.medium.jpeg = res.medium }
out.sizes.large.jpeg = res.large if (out.sizes.large) { out.sizes.large.jpeg = res.large }
}) })
}) })
.then(() => { .then(() => {