This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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))) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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); |