This repository was archived by the owner on Oct 7, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +6
-11
lines changed
Expand file tree Collapse file tree 2 files changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,6 @@ export const Media: CollectionConfig = {
3434 upload : {
3535 displayPreview : true ,
3636 focalPoint : true ,
37- mimeTypes : [ 'image/*' ] ,
3837 } ,
3938}
4039
@@ -45,18 +44,16 @@ export async function seedMedia(payload: Payload) {
4544 mediaSeedData . map ( async ( media ) => {
4645 const res = await fetch ( media . url , { method : 'GET' } )
4746
47+ const contentType = res . headers . get ( "content-type" ) || "application/octet-stream" ;
48+
4849 const data = await res . arrayBuffer ( )
4950
5051 await payload . create ( {
5152 collection : 'media' ,
5253 file : {
5354 name : media . filename ,
5455 data : Buffer . from ( data ) ,
55- mimetype : 'image/*' ,
56- // mimetype: media.filename.endsWith('.svg') ? 'image/svg+xml' :
57- // media.filename.endsWith('.png') ? 'image/png' :
58- // media.filename.endsWith('.jpg') || media.filename.endsWith('.jpeg') ? 'image/jpeg' :
59- // 'application/octet-stream', // Fallback
56+ mimetype : contentType ,
6057 size : data . byteLength ,
6158 } ,
6259 data : { alt : media . alt || media . filename } ,
Original file line number Diff line number Diff line change @@ -191,16 +191,14 @@ export async function getOrUploadMedia(
191191
192192 const data = Buffer . from ( await res . arrayBuffer ( ) ) ;
193193
194+ const contentType = res . headers . get ( "content-type" ) || "application/octet-stream" ;
195+
194196 const uploadedFile = await payload . create ( {
195197 collection : "media" ,
196198 file : {
197199 name : filename ,
198200 data,
199- mimetype : "image/*" ,
200- // mimetype: url.endsWith('.svg') ? 'image/svg+xml' :
201- // url.endsWith('.png') ? 'image/png' :
202- // url.endsWith('.jpg') || filename.endsWith('.jpeg') ? 'image/jpeg' :
203- // 'application/octet-stream',
201+ mimetype : contentType ,
204202 size : data . length ,
205203 } ,
206204 data : { alt } ,
You can’t perform that action at this time.
0 commit comments