Skip to content

Commit e360ff0

Browse files
committed
Add links to source code. Add reset operation to delete all images
1 parent e844556 commit e360ff0

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

ImageResizer/ImageResizer/Global.asax.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public class Resize
3434
public string Size { get; set; }
3535
}
3636

37+
[Route("/reset")]
38+
public class Reset { }
39+
3740
public class ImageService : Service
3841
{
3942
const int ThumbnailSize = 100;
@@ -175,6 +178,13 @@ public static Image Crop(Image Image, int newWidth, int newHeight, int startX =
175178
}
176179
}
177180
}
181+
182+
public object Any(Reset request)
183+
{
184+
Directory.GetFiles(UploadsDir).ToList().ForEach(File.Delete);
185+
Directory.GetFiles(ThumbnailsDir).ToList().ForEach(File.Delete);
186+
return HttpResult.Redirect("/");
187+
}
178188
}
179189

180190
public class AppHost : AppHostBase

ImageResizer/ImageResizer/default.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html xmlns="http://www.w3.org/1999/xhtml">
33
<head>
44
<title>Image Resizer</title>
5+
<link href="http://mythz.servicestack.net/favicon.png" rel="icon">
56
<style type="text/css">
67
body {
78
font-family: 'Droid Sans', sans-serif;
@@ -25,7 +26,7 @@
2526
#thumbnails {
2627
padding: 20px 0 0 0;
2728
}
28-
img {
29+
table img {
2930
margin: 5px;
3031
padding: 5px;
3132
background: #fff;
@@ -42,10 +43,22 @@
4243
box-shadow: 1px 4px 10px #aaa;
4344
cursor: pointer;
4445
}
46+
.links {
47+
position: absolute;
48+
top: 0;
49+
right: 10px;
50+
}
4551
</style>
4652
</head>
4753
<body>
54+
<p class="links">
55+
<a href="https://github.com/ServiceStack/ServiceStack.UseCases/blob/master/ImageResizer/ImageResizer/Global.asax.cs">1 Page C#</a> /
56+
<a href="https://github.com/ServiceStack/ServiceStack.UseCases/blob/master/ImageResizer/ImageResizer/default.html">1 HTML</a>
57+
<a href="http://www.servicestack.net"><img src="http://mythz.servicestack.net/favicon.png" title="ServiceStack" height="16" align="absmiddle" /></a>
58+
</p>
59+
4860
<h1>Image Resizer</h1>
61+
4962
<table><tr>
5063
<td>
5164
<form action="upload" method="POST" enctype="multipart/form-data">

0 commit comments

Comments
 (0)