Skip to content

Commit eb7abbc

Browse files
committed
Merge branch 'dev' into update-WebStatus
2 parents a65e9c0 + 060cc48 commit eb7abbc

12 files changed

Lines changed: 56 additions & 42 deletions

cli-linux/build-bits-linux.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
declare -x path=$1
44

55
if [ -z "$path" ]; then
6-
$path="$(pwd)/../src";
6+
$path="$(pwd)/../src";
7+
echo -e "\e[33mNo path passed. Will use $path"
78
fi
89

910
declare -a projectList=(
@@ -30,9 +31,9 @@ do
3031
echo -e "\e[33m\tRemoving old publish output"
3132
pushd $path/$project
3233
rm -rf obj/Docker/publish
33-
echo -e "\e[33m\tRestoring project"
34+
echo -e "\e[33m\tRestoring project $project"
3435
dotnet restore
35-
echo -e "\e[33m\tBuilding and publishing projects"
36+
echo -e "\e[33m\tBuilding and publishing $project"
3637
dotnet publish -o obj/Docker/publish
3738
popd
3839
done

docker-compose-external.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '2'
1+
version: '2.1'
22

33
services:
44
sql.data:

docker-compose.ci.build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '2'
1+
version: '2.1'
22

33
services:
44
ci-build:

docker-compose.nobuild.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '2'
1+
version: '2.1'
22

33
services:
44
basket.api:

docker-compose.override.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '2.1'
22

33
# The default docker-compose.override file can use the "localhost" as the external name for testing web apps within the same dev machine.
44
# The ESHOP_EXTERNAL_DNS_NAME_OR_IP environment variable is taken, by default, from the ".env" file defined like:

docker-compose.prod.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '2.1'
22

33
# The Production docker-compose file has to have the external/real IPs or DNS names for the services
44
# The ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP environment variable is taken, by default, from the ".env" file defined like:

docker-compose.vs.debug.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '2.1'
22

33
services:
44
basket.api:

docker-compose.vs.release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '2.1'
22

33
services:
44
basket.api:

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: '3'
1+
version: '2.1'
22

33
services:
44
graceperiodmanager:

src/Services/Catalog/Catalog.API/Controllers/PicController.cs

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,32 @@ public PicController(IHostingEnvironment env,
2222
_catalogContext = catalogContext;
2323
}
2424

25-
[HttpGet("{filename}")]
25+
[HttpGet("{id}")]
2626
// GET: /<controller>/
27-
public IActionResult GetImage(string filename)
27+
public async Task<IActionResult> GetImage(int id)
2828
{
29-
var webRoot = _env.WebRootPath;
30-
var path = Path.Combine(webRoot, filename);
29+
if (id <= 0)
30+
{
31+
return BadRequest();
32+
}
3133

32-
string imageFileExtension = Path.GetExtension(filename);
33-
string mimetype = GetImageMimeTypeFromImageFileExtension(imageFileExtension);
34+
var item = await _catalogContext.CatalogItems
35+
.SingleOrDefaultAsync(ci => ci.Id == id);
36+
37+
if (item != null)
38+
{
39+
var webRoot = _env.WebRootPath;
40+
var path = Path.Combine(webRoot, item.PictureFileName);
3441

35-
var buffer = System.IO.File.ReadAllBytes(path);
42+
string imageFileExtension = Path.GetExtension(item.PictureFileName);
43+
string mimetype = GetImageMimeTypeFromImageFileExtension(imageFileExtension);
44+
45+
var buffer = System.IO.File.ReadAllBytes(path);
46+
47+
return File(buffer, mimetype);
48+
}
3649

37-
return File(buffer, mimetype);
50+
return NotFound();
3851
}
3952

4053
private string GetImageMimeTypeFromImageFileExtension(string extension)
@@ -43,29 +56,29 @@ private string GetImageMimeTypeFromImageFileExtension(string extension)
4356

4457
switch (extension)
4558
{
46-
case "png":
59+
case ".png":
4760
mimetype = "image/png";
4861
break;
49-
case "gif":
62+
case ".gif":
5063
mimetype = "image/gif";
5164
break;
52-
case "jpg":
53-
case "jpeg":
65+
case ".jpg":
66+
case ".jpeg":
5467
mimetype = "image/jpeg";
5568
break;
56-
case "bmp":
69+
case ".bmp":
5770
mimetype = "image/bmp";
5871
break;
59-
case "tiff":
72+
case ".tiff":
6073
mimetype = "image/tiff";
6174
break;
62-
case "wmf":
75+
case ".wmf":
6376
mimetype = "image/wmf";
6477
break;
65-
case "jp2":
78+
case ".jp2":
6679
mimetype = "image/jp2";
6780
break;
68-
case "svg":
81+
case ".svg":
6982
mimetype = "image/svg+xml";
7083
break;
7184
default:

0 commit comments

Comments
 (0)