Skip to content

Error: You cannot upload file for not persisted record. Save record first. #26

Open

Description

@Saurabhkmr98

@Amixengineer I am facing similar issue while uploading file to s3..
These are the code snippets for options, package.json and schema.

const teacherParams = {
resource: Teacher,
options: {
listProperties: ["name", "email", "phone", "status"],
},
features: [
uploadFeature({
provider: {
aws: {
region: env.region,
bucket: env.bucket,
secretAccessKey: env.secretAccessKey,
accessKeyId: env.accessKeyId,
expires: 0,
},
},
properties: {
key: "fileUrl",
mimeType: "mimeType",
},
validation: {
mimeTypes: ["image/png", "image/jpg", "image/jpeg"],
},
multiple: true,
}),
],
};

"dependencies": {
"@admin-bro/upload": "^1.3.1",
"admin-bro": "^4.0.1",
"admin-bro-expressjs": "^2.1.1",
"admin-bro-mongoose": "^0.5.2",

const teacherSchema = new Schema({
name: String,
email: String,
about: String,
countryCode: Object,
phone: String,
createdAt: Date,
password: String,
status: Number,
permissionLevel: Number,
updatedAt: Date,
// updatedBy: Schema.Types.ObjectId,
timeZone: String,
fileUrl: [
{
type: String,
},
],
mimeType: [
{
type: String,
},
],
imageURL: String,
});

Any idea how to fix this @wojtek-krysiak @Amixengineer

Originally posted by @Saurabhkmr98 in #14 (comment)

Activity

  1. deathlock commented on Nov 18, 2022

    @deathlock

    hey @Saurabhkmr98 ,

    Did you find any solution? I am facing the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions