Skip to content

Instantly share code, notes, and snippets.

View cburnette's full-sized avatar

Chad Burnette cburnette

View GitHub Profile
@cburnette
cburnette / Upload file from local disk to a specific Box folder in C#
Last active August 25, 2023 04:14
Upload file from local disk to a specific Box folder in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Box.V2;
using Box.V2.Auth;
using Box.V2.Config;
using Box.V2.Exceptions;
using Box.V2.Models;
@cburnette
cburnette / Iterate Box folders in C#
Last active July 28, 2018 06:34
This code snippet will connect to a Box account and loop through all the folders recursively, printing out all the filenames, while highlighting in red files that have a modified_at date older than the specified threshold. In other words, it highlights files that haven't been changed in a while.
//requires .NET 4.5
using Box.V2;
using Box.V2.Auth;
using Box.V2.Config;
using Box.V2.Exceptions;
using Box.V2.Models;
using Nito.AsyncEx;
using System;
using System.Collections.Concurrent;
@cburnette
cburnette / Upload file from local disk to a specific Box folder with auto-refreshing tokens using encrypted tokens in C#
Last active July 25, 2018 06:47
Upload file from local disk to a specific Box folder with auto-refreshing tokens using encrypted tokens in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Box.V2;
using Box.V2.Auth;
using Box.V2.Config;
using Box.V2.Exceptions;
using Box.V2.Models;
@cburnette
cburnette / Upload file from local disk to a specific Box folder with auto-refreshing tokens in C#
Last active February 22, 2018 15:48
Upload file from local disk to a specific Box folder with auto-refreshing tokens in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Box.V2;
using Box.V2.Auth;
using Box.V2.Config;
using Box.V2.Exceptions;
using Box.V2.Models;
using DocuSign.eSign.Api;
using DocuSign.eSign.Model;
using DocuSign.eSign.Client;
using System.Collections.Generic;
using System.IO;
using System;
namespace BasicMvcSample.Helpers
{
public class DocuSignHelper
public async Task<FileStreamResult> Thumbnail(string id)
{
var thumbBytes = await BoxHelper.UserClient().FilesManager.GetThumbnailAsync(id, minHeight: 256, minWidth: 256, maxHeight: 256, maxWidth: 256);
return new FileStreamResult(thumbBytes, "image/png");
}
// The Box Auth Header. Add your access token.
var headers = { Authorization: 'Bearer @ViewBag.AccessToken'};
var uploadUrl = 'https://upload.box.com/api/2.0/files/content';
var files = fileSelect.files;
var formData = new FormData();
formData.append('files', files[0], files[0].name);
// Add the destination folder for the upload to the form
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
namespace BasicMvcSample.Helpers
{
public static class CacheHelper
{
using Box.V2;
using Box.V2.Auth;
using Box.V2.Config;
using Box.V2.JWTAuth;
using Box.V2.Models;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
<add key="boxClientId" value="59oj4w7tft85e3t43v1dk4fbqub2e7bo" />
<add key="boxClientSecret" value="MdSMRvyNNBkTAYZmFTgPXJuVfxf2af5s" />
<add key="boxEnterpriseId" value="653871" />
<add key="boxPrivateKeyPassword" value="BoxTraining1234" />
<add key="boxPublicKeyId" value="eq2emlah" />