mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 01:47:13 +00:00 
			
		
		
		
	Clean up
Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
		
							parent
							
								
									f9d924dd47
								
							
						
					
					
						commit
						2b5c332e09
					
				| @ -89,44 +89,6 @@ module.exports = { | |||||||
|     ctx.body = { data }; |     ctx.body = { data }; | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   async replaceFile(ctx) { |  | ||||||
|     const { id } = ctx.params; |  | ||||||
| 
 |  | ||||||
|     const uploadService = strapi.plugins.upload.services.upload; |  | ||||||
| 
 |  | ||||||
|     // Retrieve provider configuration.
 |  | ||||||
|     const { enabled } = strapi.plugins.upload.config; |  | ||||||
| 
 |  | ||||||
|     // Verify if the file upload is enable.
 |  | ||||||
|     if (enabled === false) { |  | ||||||
|       throw strapi.errors.badRequest(null, { |  | ||||||
|         errors: [{ id: 'Upload.status.disabled', message: 'File upload is disabled' }], |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     const data = await strapi.plugins['upload'].services.upload.fetch({ id }); |  | ||||||
| 
 |  | ||||||
|     if (!data) { |  | ||||||
|       return ctx.notFound('file.notFound'); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     const { fileInfo } = await validateUploadBody(uploadSchema, ctx.request.body); |  | ||||||
| 
 |  | ||||||
|     const { file = {} } = ctx.request.files || {}; |  | ||||||
| 
 |  | ||||||
|     if (_.isUndefined(file)) { |  | ||||||
|       throw strapi.errors.badRequest(null, { |  | ||||||
|         errors: [{ id: 'Upload.status.empty', message: 'File is missing' }], |  | ||||||
|       }); |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     const enhancedFile = uploadService.enhanceFile(file, fileInfo); |  | ||||||
| 
 |  | ||||||
|     const updatedFile = await uploadService.update(id, enhancedFile); |  | ||||||
| 
 |  | ||||||
|     ctx.body = updatedFile; |  | ||||||
|   }, |  | ||||||
| 
 |  | ||||||
|   async find(ctx) { |   async find(ctx) { | ||||||
|     const data = await strapi.plugins['upload'].services.upload.fetchAll(ctx.query); |     const data = await strapi.plugins['upload'].services.upload.fetchAll(ctx.query); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Alexandre Bodin
						Alexandre Bodin