public async Task <ProductFolderPath> getProductFilePathAsync(Product product) { var root = $"{product?.Id ?? 0}"; ProductFolderPath filePath = new ProductFolderPath() { RootPath = root, DefaultPath = $"{root}/default", }; return(filePath); }
public async Task <string> SaveProductImage(ProductFolderPath filePath, string type, string base64Data) { var path = await settingQueries.GetValueAsync(SettingKeys.Path_Product); string parentFolder = filePath.DefaultPath; string fullPath = $"{path}/{parentFolder}"; string filename = $"prod_{DateTime.Now.Ticks}.{type}"; if (!Directory.Exists(fullPath)) { Directory.CreateDirectory(fullPath); } File.WriteAllBytes($"{fullPath}/{filename}", Convert.FromBase64String(base64Data)); return($"{parentFolder}/{filename}"); }