We have hosted our ASP.Net website in Azure. I have written a continuous web job to process some of my files in background on queue trigger. Sometimes the process involves getting an image from an url and save a copy in predefined folder of our site.
We already have a function for getting an image and saving to folder in the codes of main site, so I was using that.
During development, I ran the .exe manually to check if the trigger works. Everything is fine until the image upload process. It can not map the path to given folder. Code is below, the filepath
variable is always null, so I get an exception here and the job fails. Is there a better way to do this? Is this because I ran the job manually, or some functions I am using in wrong way?
public class MyHelper
{
public const string UPLOAD_URL = "/Uploads/";
// other functions
// ....
private static void GetFileLocation(string prefix, string imageName, out string fileUrl, out string saveLocation)
{
var filename = imageName;
// filepath is always null
var filePath = HostingEnvironment.MapPath(UPLOAD_URL);
fileUrl = Path.Combine(UPLOAD_URL, filename);
// this here throws the exception because filepath is null
saveLocation = Path.Combine(filePath, filename);
}
}
Appreciate any insight on this. Thanks!!