Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] - Customize form data to submit local files to CDN #519

Open
mattvan83 opened this issue Jan 20, 2025 · 2 comments
Open

[FEATURE] - Customize form data to submit local files to CDN #519

mattvan83 opened this issue Jan 20, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@mattvan83
Copy link

Summary

Would it be easy for specific field (String) of a model corresponding to a CDN url of a media file, to modify the form of the model in edit/create mode in order to enable to load local media file and enable the uploading of the file to CDN when saving, and finally returning the url of the file from the CDN in the model field?

Basic Example

Based on the prisma model:

model listenings {
  id                   String   @id @default(auto()) @map("_id") @db.ObjectId
  v                    Int      @map("__v")
  arrangement          String?
  artwork              String?
  audioUrl             String
  authorMusic          String
  authorText           String?
  createdAt            DateTime @db.Date
  lastListening        Boolean
  recordingDate        DateTime @db.Date
  thumbnailDescription String
  thumbnailUrl         String
  title                String
  updatedAt            DateTime @db.Date
}

The audioUrl field correspond to the CDN url of an audio file
The thumbnailUrl field correspond to the CDN url of an image file

Would it be feasible to :

  1. Add input local file in form data of these two fields in edit/create mode?
  2. Launch a specified routine for uploading (and else...) the files onto the CDN when saving the model document

Drawbacks

No response

Unresolved questions

No response

@mattvan83 mattvan83 added the enhancement New feature or request label Jan 20, 2025
@foyarash
Copy link
Collaborator

Hello @mattvan83

This is already possible by setting the format property of your field to file https://next-admin.js.org/docs/api/model-configuration#editfields-property

This, combined with handler.upload, will allow you to do what you want !

@mattvan83
Copy link
Author

Hello @foyarash thanks for your quick reply!

I will try your solution asap and let this issue open meanwhile in case of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants