Skip to content

Instantly share code, notes, and snippets.

View trailmax's full-sized avatar

Max Vasilyev trailmax

View GitHub Profile
@trailmax
trailmax / AzureStorageApi
Created January 9, 2014 02:43
Uploading large files to Azure Blob Storage via REST API. Code for blog post http://tech.trailmax.info/2014/01/uploading-large-files-to-azure-blob-storage-through-rest-api/
public class AzureStorageApi
{
private const string AzureApiVersion = "2012-02-12";
private const int BlockSize = 4 * 1024 * 1024;
public void UploadFile(string fullFilePath, string blobSasUri, Dictionary<string, string> metadata = null, int timeout = 60)
{
var blocks = new List<String>();
var tasks = new List<Task>();
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PackagePath Condition=" '$(PackagePath)'=='' ">website</PackagePath>
<EnableAddReplaceToUpdatePacakgePath Condition=" '$(EnableAddReplaceToUpdatePacakgePath)'=='' ">true</EnableAddReplaceToUpdatePacakgePath>
@trailmax
trailmax / HttpSimulator.cs
Created November 21, 2013 23:03
HttpSimulator code from Phil Haak (http://haacked.com/archive/2007/06/19/unit-tests-web-code-without-a-web-server-using-httpsimulator.aspx) This version is StyleCop-ed. Also backing-up in case that page dies. Linked to my blog-post
using System;
using System.Collections.Specialized;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Configuration;
using System.Web.Hosting;
using System.Web.SessionState;
@trailmax
trailmax / AzureStorageApi
Last active March 10, 2021 11:02
Unit testing the functionality to upload files to Azure Blob Storage via REST API. For blog post: http://tech.trailmax.info/2013/11/how-to-test-code-for-accessing-azure-storage-rest-api/ Please note, this implementation only supports file up to 64Mb in size. Anything larger and you need to chop files in pieces and upload them separately. There i…
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
namespace PackageUploader.Azure
{
public class AzureStorageApi
{
public void UploadFile(String fullFilePath, String blobSasUri, Dictionary<String, String> metadata = null)
@trailmax
trailmax / gist:5548014
Created May 9, 2013 15:01
List of actions in a controller. Ignoring actions that come from base controller.
public virtual ActionResult SiteMap()
{
var assembly = Assembly.GetExecutingAssembly();
var controllers = assembly.GetTypes().Where(x => x != typeof(BaseController) && typeof(BaseController).IsAssignableFrom(x)).ToList();
controllers = controllers.Where(c => !c.Name.StartsWith("T4MVC")).ToList();
var controller = controllers.FirstOrDefault(c => c.FullName.Contains("HomePage"));
var actions = GetActionResults(controller);