Exemple #1
0
        public WhenRetrievingFileAddressesForMedia()
        {
            mediaSourceUrl = "http://wow.zamimg.com/images/hearthstone/cards/enus/medium/{0}.png";
            mediaPath      = "~/App_Data/media/";
            namingFormat   = "{0}.png";
            //This is a fake localBaseDirectory, on the real call we pass this parameter by calling
            //CreateDocument() (a method on the service) from the Controller that uses the service.

            localBaseDirectory = "C:/ProgramFiles/App_Data/media/";
            id = "1";

            mediaService = new MediaRetrievalService(mediaSourceUrl, mediaPath);
        }
Exemple #2
0
        // GET: Media
        public ActionResult Card(string id)
        {
            //Create the service
            var mediaService = new MediaRetrievalService(mediaSourceUrl, mediaPath);
            //Get the localbaseDirectory (using the current HTTP Context)
            var localBaseDirectory = mediaService.createDirectory();
            //Create the path to the file
            var localFile = mediaService.getFile(namingFormat, id, localBaseDirectory);

            //Download the file if not exists on the local directory
            mediaService.DownloadFromSource(id, localFile);
            //Return the file to the view
            return(File(localFile, "image/png"));
        }