-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- fixed issues with file upload in PHP
- added ImageResult (only to use with UImage which is really alpha) - fixed FileResult - removed controllerName and action from UrlHelper methods and derivatives (use the data object to pass controller info) - added writeBytes to HttpResponse
- Loading branch information
1 parent
45c6141
commit 4612212
Showing
8 changed files
with
124 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package ufront.web.mvc; | ||
|
||
import thx.error.NullArgument; | ||
import uimage.IImage<Dynamic>; | ||
|
||
/** | ||
* ... | ||
* @author Franco Ponticelli | ||
*/ | ||
|
||
class ImageResult extends ActionResult | ||
{ | ||
public var format : ImageFormat; | ||
public var image : IImage<Dynamic>; | ||
|
||
public function new(image : IImage<Dynamic>, ?format : ImageFormat) | ||
{ | ||
if (null == format) | ||
format = Png; | ||
this.format = format; | ||
NullArgument.throwIfNull(image, "image"); | ||
this.image = image; | ||
} | ||
|
||
override function executeResult(controllerContext : ControllerContext) | ||
{ | ||
NullArgument.throwIfNull(controllerContext, "controllerContext"); | ||
var response = controllerContext.response; | ||
var bytes = switch(format) | ||
{ | ||
case Jpeg: | ||
response.contentType = "image/jpeg"; | ||
image.toBytesJpeg(); | ||
case Png: | ||
response.contentType = "image/png"; | ||
image.toBytesPng(); | ||
case Gif: | ||
response.contentType = "image/gif"; | ||
image.toBytesGif(); | ||
} | ||
response.setHeader("Content-Length", "" + bytes.length); | ||
// response.setHeader("Last-Modified", DateTools.format(Date.now(), '%a, %d %b %Y %H:%M:%S') + ' GMT'); | ||
response.writeBytes(bytes); | ||
} | ||
} | ||
|
||
enum ImageFormat | ||
{ | ||
Jpeg; | ||
Png; | ||
Gif; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters