Skip to content

Instantly share code, notes, and snippets.

View nickharris's full-sized avatar

Nick Harris nickharris

View GitHub Profile
@nickharris
nickharris / gist:3785382
Created September 26, 2012 01:04
SAS part 1 - xaml click
...
</Grid>
...
<Page.BottomAppBar>
<AppBar>
<Button Name="btnTakePhoto" Style="{StaticResource PhotoAppBarButtonStyle}"
Click="OnTakePhotoClick" />
</AppBar>
</Page.BottomAppBar>
...
@nickharris
nickharris / gist:3785387
Created September 26, 2012 01:04
SAS part 2 - Camera capture
using Windows.Media.Capture;
private async void OnTakePhotoClick(object sender, RoutedEventArgs e)
{
//Take photo or video
CameraCaptureUI cameraCapture = new CameraCaptureUI();
StorageFile media = await cameraCapture.CaptureFileAsync(CameraCaptureUIMode.PhotoOrVideo);
@nickharris
nickharris / gist:3785391
Created September 26, 2012 01:06
Part 3 - insert todoitem to trigger SAS creation
private async void OnTakePhotoClick(object sender, RoutedEventArgs e)
{
//Take photo or video
CameraCaptureUI cameraCapture = new CameraCaptureUI();
StorageFile media = await cameraCapture.CaptureFileAsync(CameraCaptureUIMode.PhotoOrVideo);
//add todo item to trigger insert operation which returns item.SAS
var todoItem = new TodoItem() { Text = "test image", ImageName = media.Name };
await todoTable.InsertAsync(todoItem);
@nickharris
nickharris / gist:3785397
Created September 26, 2012 01:06
Part 4 - uploading the blob using the generated SAS with the HttpClient
private async void OnTakePhotoClick(object sender, RoutedEventArgs e)
{
//Take photo or video
CameraCaptureUI cameraCapture = new CameraCaptureUI();
StorageFile media = await cameraCapture.CaptureFileAsync(CameraCaptureUIMode.PhotoOrVideo);
//add todo item
var todoItem = new TodoItem() { Text = "test image", ImageName = media.Name };
await todoTable.InsertAsync(todoItem);
@nickharris
nickharris / gist:4058313
Created November 12, 2012 09:18
blob sas demo todoitem
public class TodoItem
{
public int Id { get; set; }
[DataMember(Name = "text")]
public string Text { get; set; }
[DataMember(Name = "complete")]
public bool Complete { get; set; }
private async void OnTakePhotoClick(object sender, RoutedEventArgs e)
{
//Take photo or video
CameraCaptureUI cameraCapture = new CameraCaptureUI();
StorageFile media = await cameraCapture.CaptureFileAsync(CameraCaptureUIMode.PhotoOrVideo);
//add todo item to trigger insert operation which returns item.SAS
var todoItem = new TodoItem() {
ContainerName = "mypics",
ResourceName= media.Name,
@nickharris
nickharris / gist:4063407
Created November 13, 2012 01:50
Upload image direct to blob storage using SAS and the Storage Client library for Windows CTP
...
using Microsoft.WindowsAzure.Storage.Auth;
using Microsoft.WindowsAzure.Storage.Blob;
...
private async void OnTakePhotoClick(object sender, RoutedEventArgs e)
{
//Take photo or video
var azure = require('azure');
var qs = require('querystring');
function insert(item, user, request) {
var accountName = '<replace with your storage account name>';
var accountKey = '<replace with your storage account key>';
var host = accountName + '.blob.core.windows.net';
var canonicalizedResource = '/' + item.containerName + '/' + item.resourceName;
//Must be lowercase
item.containerName = item.containerName.toLowerCase();
@nickharris
nickharris / gist:4357369
Created December 22, 2012 03:34
Windows Azure Mobile Services Scheduler
function CheckFeed() {
getUpdatesAndNotify();
}
var request = require('request');
function getUpdatesAndNotify() {
request('http://search.twitter.com/search.json?q=@cloudnick&rpp=2',
function tweetsLoaded (error, response, body) {
var results = JSON.parse(body).results;
if(results){
@nickharris
nickharris / gist:4949367
Last active December 13, 2015 17:38
SensorReading
using System;
using Microsoft.SPOT;
using Microsoft.Azure.Zumo.MicroFramework.Core;
namespace SensorDemoMobileServices
{
public class SensorReading : IMobileServiceEntity
{
public int Id { get; set; }
public string SensorID { get; set; }