increase upload max and update error messages
This commit is contained in:
parent
8a4e67e9f0
commit
e09e1398fd
|
@ -1,4 +1,4 @@
|
|||
import { USER_ID, IMAGE_PIXELS_MAX, UPLOAD_SIZE_MAX, UPLOAD_SIZE_MAX_AVATAR, UPLOAD_TYPES_ALLOW, AWS_S3_URL_REGEXP } from '@/lib/constants'
|
||||
import { USER_ID, IMAGE_PIXELS_MAX, UPLOAD_SIZE_MAX, UPLOAD_SIZE_MAX_AVATAR, UPLOAD_TYPES_ALLOW, AWS_S3_URL_REGEXP, AVATAR_TYPES_ALLOW } from '@/lib/constants'
|
||||
import { createPresignedPost } from '@/api/s3'
|
||||
import { GqlAuthenticationError, GqlInputError } from '@/lib/error'
|
||||
import { msatsToSats } from '@/lib/format'
|
||||
|
@ -12,15 +12,21 @@ export default {
|
|||
Mutation: {
|
||||
getSignedPOST: async (parent, { type, size, width, height, avatar }, { models, me }) => {
|
||||
if (UPLOAD_TYPES_ALLOW.indexOf(type) === -1) {
|
||||
throw new GqlInputError(`image must be ${UPLOAD_TYPES_ALLOW.map(t => t.replace('image/', '')).join(', ')}`)
|
||||
throw new GqlInputError(`upload must be ${UPLOAD_TYPES_ALLOW.map(t => t.replace(/^(image|video)\//, '')).join(', ')}`)
|
||||
}
|
||||
|
||||
if (size > UPLOAD_SIZE_MAX) {
|
||||
throw new GqlInputError(`image must be less than ${UPLOAD_SIZE_MAX / (1024 ** 2)} megabytes`)
|
||||
throw new GqlInputError(`upload must be less than ${UPLOAD_SIZE_MAX / (1024 ** 2)} megabytes`)
|
||||
}
|
||||
|
||||
if (avatar && size > UPLOAD_SIZE_MAX_AVATAR) {
|
||||
throw new GqlInputError(`image must be less than ${UPLOAD_SIZE_MAX_AVATAR / (1024 ** 2)} megabytes`)
|
||||
if (avatar) {
|
||||
if (AVATAR_TYPES_ALLOW.indexOf(type) === -1) {
|
||||
throw new GqlInputError(`avatar must be ${AVATAR_TYPES_ALLOW.map(t => t.replace('image/', '')).join(', ')}`)
|
||||
}
|
||||
|
||||
if (size > UPLOAD_SIZE_MAX_AVATAR) {
|
||||
throw new GqlInputError(`avatar must be less than ${UPLOAD_SIZE_MAX_AVATAR / (1024 ** 2)} megabytes`)
|
||||
}
|
||||
}
|
||||
|
||||
if (width * height > IMAGE_PIXELS_MAX) {
|
||||
|
|
|
@ -41,7 +41,6 @@ export const FileUpload = forwardRef(({ children, className, onSelect, onUpload,
|
|||
} catch (e) {
|
||||
toaster.danger('error initiating upload: ' + e.message || e.toString?.())
|
||||
onError?.({ ...variables, name: file.name, file })
|
||||
reject(e)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ export const NOFOLLOW_LIMIT = 1000
|
|||
export const UNKNOWN_LINK_REL = 'noreferrer nofollow noopener'
|
||||
export const BOOST_MULT = 5000
|
||||
export const BOOST_MIN = BOOST_MULT * 10
|
||||
export const UPLOAD_SIZE_MAX = 25 * 1024 * 1024
|
||||
export const UPLOAD_SIZE_MAX = 50 * 1024 * 1024
|
||||
export const UPLOAD_SIZE_MAX_AVATAR = 5 * 1024 * 1024
|
||||
export const IMAGE_PIXELS_MAX = 35000000
|
||||
// backwards compatibile with old media domain env var and precedence for docker url if set
|
||||
|
@ -24,6 +24,7 @@ export const UPLOAD_TYPES_ALLOW = [
|
|||
'video/mpeg',
|
||||
'video/webm'
|
||||
]
|
||||
export const AVATAR_TYPES_ALLOW = UPLOAD_TYPES_ALLOW.filter(t => t.startsWith('image/'))
|
||||
export const INVOICE_ACTION_NOTIFICATION_TYPES = ['ITEM_CREATE', 'ZAP', 'DOWN_ZAP', 'POLL_VOTE']
|
||||
export const BOUNTY_MIN = 1000
|
||||
export const BOUNTY_MAX = 10000000
|
||||
|
|
Loading…
Reference in New Issue