Sending files to Clients on WebMap migrations

Suppose the original application had a situation where you needed send a file to the client. How do you do that on a migrated app?

Well there are several ways to do that. The following is just one of the multiple ways.

In this scenario. Suppose you had a Windows Forms where you create a temporary file. On WebMap you would need to do this:

       public static void SendToClient(string pathToTempFile)
        {
            // Retrieve storage account from connection string. 
            // just add one to your Web.Config file
            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);

            // Create the blob client.
            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            // Retrieve a reference to a container.
            CloudBlobContainer container = blobClient.GetContainerReference("reportscontainer");
            // Create the container if it doesn't already exist.
            try
            {
                container.CreateIfNotExists();
            }
            catch {
                //Just ignore error is container already exists
            }
            container.SetPermissions(new BlobContainerPermissions { PublicAccess = BlobContainerPublicAccessType.Blob });

            // Retrieve reference to a blob named "myblob".
            CloudBlockBlob blob = container.GetBlockBlobReference(token);

            // Create or overwrite the "myblob" blob with contents from a local file.
            using (var fileStream = System.IO.File.OpenRead(pathToFile))
            {
                blob.UploadFromStream(fileStream);
            }

            //Set the expiry time and permissions for the blob.
            //In this case the start time is specified as a few minutes in the past, to mitigate clock skew.
            //The shared access signature will be valid immediately.
            SharedAccessBlobPolicy sasConstraints = new SharedAccessBlobPolicy();
            sasConstraints.SharedAccessStartTime = DateTime.UtcNow.AddMinutes(-5);
            sasConstraints.SharedAccessExpiryTime = DateTime.UtcNow.AddHours(24);
            sasConstraints.Permissions = SharedAccessBlobPermissions.Read;
             var url = blob.Uri + sasBlobToken;
            //Generate the shared access signature on the blob, setting the constraints directly on the signature.
            string sasBlobToken = blob.GetSharedAccessSignature(sasConstraints);

            //Return the URI string for the container, including the SAS token.
            //Now we need to send this URL to the client
            var viewManager = StaticContainer.Resolve<IViewManager>();
            viewManager.ExecOnClient("clienturlopen",new {TargetURL = url });
        }

Ok. Now on the client you just need to register a client command as explained on http://mrojas.ghost.io/creating-a-client-command-handler-on-webmap4/