`coldbox.system.web.context.RequestContext` in thi...
# box-products
r
coldbox.system.web.context.RequestContext
in this class i want to get file with the method
Copy code
function uploadFile(event, rc, prc) {
    
       var uploadedFile = event.getFile('image'); 
	
			if (uploadedFile) {
				var destinationPath = "path/to/destination/directory";
				var filename = uploadedFile.serverFile;
				var fullFilePath = destinationPath + filename;
				var fileUtils = new coldbox.system.util.FileUtils();
				fileUtils.move(uploadedFile.serverFile, fullFilePath);
	
				// Return a success response
				return {
					success: true,
					message: "File uploaded successfully",
				};
			} else {
				// Return a failure response if no file was uploaded
				return {
					success: false,
					message: "No file uploaded",
				};
			}
   
}
and i am calling from postman then is says
event.getFile('image');
not defined in requestContext how would i get file from request context of an API
Copy code
{
  "data": {
    "environment": {
      "currentRoutedUrl": "api/upload/",
      "timestamp": "2023-07-26T05:36:57Z",
      "currentRoute": "api/upload/",
      "currentEvent": "S3Handler.index"
    },
    "exception": {
      "stack": [
        "E:\\Learning\\coldbox learn\\myRestApp\\handlers\\S3Handler.cfc:24",
        "E:\\Learning\\coldbox learn\\myRestApp\\coldbox\\system\\RestHandler.cfc:58",
        "E:\\Learning\\coldbox learn\\myRestApp\\coldbox\\system\\web\\Controller.cfc:998",
        "E:\\Learning\\coldbox learn\\myRestApp\\coldbox\\system\\web\\Controller.cfc:713",
        "E:\\Learning\\coldbox learn\\myRestApp\\coldbox\\system\\Bootstrap.cfc:290",
        "E:\\Learning\\coldbox learn\\myRestApp\\coldbox\\system\\Bootstrap.cfc:506",
        "E:\\Learning\\coldbox learn\\myRestApp\\Application.cfc:112"
      ],
      "detail": "",
      "type": "expression",
      "extendedInfo": ""
    }
  },
  "error": true,
  "pagination": {
    "totalPages": 1,
    "maxRows": 0,
    "offset": 0,
    "page": 1,
    "totalRecords": 0
  },
  "messages": [
    "An exception ocurred: component [coldbox.system.web.context.RequestContext] has no function with name [getFile]"
  ]
}
how would i get files from event