mirror of
https://github.com/plankanban/planka.git
synced 2025-07-24 15:49:46 +02:00
feat: Add S3 support for uploads (#938)
This commit is contained in:
parent
06a574f766
commit
f20a3d50f5
16 changed files with 579 additions and 24 deletions
|
@ -26,6 +26,17 @@ module.exports = {
|
|||
type: 'string',
|
||||
required: true,
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
},
|
||||
url: {
|
||||
type: 'string',
|
||||
allowNull: true,
|
||||
},
|
||||
thumb: {
|
||||
type: 'string',
|
||||
allowNull: true,
|
||||
},
|
||||
|
||||
// ╔═╗╔╦╗╔╗ ╔═╗╔╦╗╔═╗
|
||||
// ║╣ ║║║╠╩╗║╣ ║║╚═╗
|
||||
|
@ -48,12 +59,20 @@ module.exports = {
|
|||
},
|
||||
|
||||
customToJSON() {
|
||||
return {
|
||||
..._.omit(this, ['dirname', 'filename', 'image.thumbnailsExtension']),
|
||||
url: `${sails.config.custom.attachmentsUrl}/${this.id}/download/${this.filename}`,
|
||||
coverUrl: this.image
|
||||
let { url, thumb } = this;
|
||||
if (!url) {
|
||||
url = `${sails.config.custom.attachmentsUrl}/${this.id}/download/${this.filename}`;
|
||||
}
|
||||
if (!thumb) {
|
||||
thumb = this.image
|
||||
? `${sails.config.custom.attachmentsUrl}/${this.id}/download/thumbnails/cover-256.${this.image.thumbnailsExtension}`
|
||||
: null,
|
||||
: null;
|
||||
}
|
||||
|
||||
return {
|
||||
..._.omit(this, ['type', 'dirname', 'filename', 'image.thumbnailsExtension']),
|
||||
url,
|
||||
coverUrl: thumb,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
|
|
@ -79,11 +79,26 @@ module.exports = {
|
|||
},
|
||||
|
||||
customToJSON() {
|
||||
let url = '';
|
||||
let coverUrl = '';
|
||||
if (this.backgroundImage) {
|
||||
if (this.backgroundImage.original) {
|
||||
url = this.backgroundImage.original;
|
||||
} else {
|
||||
url = `${sails.config.custom.projectBackgroundImagesUrl}/${this.backgroundImage.dirname}/original.${this.backgroundImage.extension}`;
|
||||
}
|
||||
if (this.backgroundImage.thumb) {
|
||||
coverUrl = this.backgroundImage.thumb;
|
||||
} else {
|
||||
coverUrl = `${sails.config.custom.projectBackgroundImagesUrl}/${this.backgroundImage.dirname}/cover-336.${this.backgroundImage.extension}`;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
..._.omit(this, ['backgroundImage']),
|
||||
backgroundImage: this.backgroundImage && {
|
||||
url: `${sails.config.custom.projectBackgroundImagesUrl}/${this.backgroundImage.dirname}/original.${this.backgroundImage.extension}`,
|
||||
coverUrl: `${sails.config.custom.projectBackgroundImagesUrl}/${this.backgroundImage.dirname}/cover-336.${this.backgroundImage.extension}`,
|
||||
url,
|
||||
coverUrl,
|
||||
},
|
||||
};
|
||||
},
|
||||
|
|
|
@ -148,6 +148,14 @@ module.exports = {
|
|||
|
||||
customToJSON() {
|
||||
const isDefaultAdmin = this.email === sails.config.custom.defaultAdminEmail;
|
||||
let avatarUrl = '';
|
||||
if (this.avatar) {
|
||||
if (this.avatar.square) {
|
||||
avatarUrl = this.avatar.square;
|
||||
} else {
|
||||
avatarUrl = `${sails.config.custom.userAvatarsUrl}/${this.avatar.dirname}/square-100.${this.avatar.extension}`;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
..._.omit(this, ['password', 'isSso', 'avatar', 'passwordChangedAt']),
|
||||
|
@ -155,9 +163,7 @@ module.exports = {
|
|||
isRoleLocked: (this.isSso && !sails.config.custom.oidcIgnoreRoles) || isDefaultAdmin,
|
||||
isUsernameLocked: (this.isSso && !sails.config.custom.oidcIgnoreUsername) || isDefaultAdmin,
|
||||
isDeletionLocked: isDefaultAdmin,
|
||||
avatarUrl:
|
||||
this.avatar &&
|
||||
`${sails.config.custom.userAvatarsUrl}/${this.avatar.dirname}/square-100.${this.avatar.extension}`,
|
||||
avatarUrl,
|
||||
};
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue