Skip to content

Instantly share code, notes, and snippets.

View File Concurrency Example
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++)
{
View MongoDB_GridFS_Helpers.cs
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)))
{
View S3StreamResponse.cs
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; }
}
View controller.cs
[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);