Skip to content

Instantly share code, notes, and snippets.

View BaileyMillerSSI's full-sized avatar

Bailey Miller BaileyMillerSSI

View GitHub Profile
class Program
{
static string OutputPath = @"C:\Users\baile\Downloads\Data";
static HttpClient Web = new HttpClient();
static async Task Main(string[] args)
{
var Codes = new List<int>();
for (int i = 0; i < 200; i++)
{
@BaileyMillerSSI
BaileyMillerSSI / MongoDB_GridFS_Helpers.cs
Last active December 20, 2019 19:43
Added example program
public static class Helpers
{
public static async Task<ObjectId> UploadFile(this GridFSBucket bucket, string localPath ,IProgress<BasicProgress> progress)
{
byte[] buffer = new byte[255000];
ObjectId id;
using (var localStream = File.OpenRead(localPath))
using (var uploadStream = await bucket.OpenUploadStreamAsync(Path.GetFileName(localPath)))
{
public class S3StreamResponse : S3Response
{
public Stream FileStream { get; set; }
public String FileName { get; set; }
public String Content_Type { get; set; }
public long Content_Length { get; set; }
public DateTime LastModified { get; set; }
}
[HttpPost("{bucketName}"), DisableRequestSizeLimit]
public async Task<IActionResult> UploadFile([FromRoute]string bucketName)
{
var file = Request.Form.Files[0];
var response = await _service.UploadFileAsync(bucketName, file);
if (response.Status == System.Net.HttpStatusCode.OK)
{
return Ok(response);