Module

@adminjs/upload

Classes

BaseProvider

Type Definitions

object

# AWSOptions

AWS Credentials which can be set for S3 file upload. If not given, 'aws-sdk' will try to fetch them from environmental variables.

Properties:
Name Type Attributes Description
accessKeyId string <optional>

AWS IAM accessKeyId. By default its value is taken from AWS_ACCESS_KEY_ID env variable

secretAccessKey string <optional>

AWS IAM secretAccessKey. By default its value is taken from AWS_SECRET_ACCESS_KEY env variable

region string

AWS region where your bucket was created.

bucket string

S3 Bucket where files will be stored

expires number <optional>

indicates how long links should be available after page load (in minutes). , Default to 24h. If set to 0 adapter will mark uploaded files as PUBLIC ACL.

View Source adminjs-upload/src/features/upload-file/providers/aws-provider.ts, line 54

object

# GCPOptions

Google Storage options which can be set for GCP file upload. In order to setup GCP credentials you have to follow this tutorial. Basically it comes down to downloading service account and setting GOOGLE_APPLICATION_CREDENTIALS env variable. After that you are ready to go.

Properties:
Name Type Attributes Description
bucket string

Google Storage Bucket name, where files will be stored

expires number <optional>

indicates how long links should be available after page load (in minutes). , Default to 24h. If set to 0 adapter will mark uploaded files as public.

View Source adminjs-upload/src/features/upload-file/providers/gcp-provider.ts, line 52

object

# LocalUploadOptions

Options required by the LocalAdapter

Properties:
Name Type Description
bucket string

Path where files will be stored. For example: path.join(__dirname, '../public')

View Source adminjs-upload/src/features/upload-file/providers/local-provider.ts, line 32

object

# UploadOptions

Configuration options for @adminjs/upload feature

Properties:
Name Type Attributes Description
provider object | BaseProvider

Options for the provider

aws AWSOptions <optional>

AWS Credentials

gcp GCPOptions <optional>

GCP Credentials

local LocalUploadOptions <optional>

Storage on the local drive

properties object
key string

Property under which file key (path) will be stored

file string <optional>

Virtual property where uploaded file will be passed to from , frontend to the backend in the request payload. Default to file

filesToDelete string <optional>

Virtual property needed used when upload works in multiple mode. It contains all the keys , of the files which should be deleted. Default to filesToDelete

filePath string <optional>

Virtual property where path for uploaded file will be , generated and accessible on the frontend. , Default to filePath

bucket string <optional>

Property under which file bucket (folder) will be stored

mimeType string <optional>

Property under which file mime type will be stored. , When you give this system will show a correct icon by the , uploaded file

size string <optional>

Property under which file size will be stored

filename string <optional>

Property under which file name will be stored

uploadPath UploadPathFunction <optional>

Function which defines where the file should be placed inside the bucket. , Default to ${record.id()}/${filename}.

multiple boolean <optional>

Indicates if feature should handle uploading multiple files

validation object <optional>

Validation rules

mimeTypes Array.<string> <optional>

Available mime types

maxSize number <optional>

Maximum size in bytes

View Source adminjs-upload/src/features/upload-file/types/upload-options.type.ts, line 8

# UploadPathFunction(record, filename)

Function which defines where in the bucket file should be stored. If we have 2 uploads in one resource we might need to set them to

  • ${record.id()}/upload1/${filename}
  • ${record.id()}/upload2/${filename}

By default system uploads files to: ${record.id()}/${filename}

Parameters:
Name Type Description
record BaseRecord

Record for which file is uploaded

filename string

filename with extension

View Source adminjs-upload/src/features/upload-file/types/upload-options.type.ts, line 49