Skip to content

Instantly share code, notes, and snippets.

View setu1421's full-sized avatar

Setu Kumar Basak setu1421

View GitHub Profile
@setu1421
setu1421 / uploadfilestep3
Created April 6, 2019 07:32
Build and send the multipart complete request
//Step 3: build and send the multipart complete request
if (lastPart)
{
eTags.Add(new PartETag
{
PartNumber = partNumber,
ETag = uploadResponse.ETag
});
var completeRequest = new CompleteMultipartUploadRequest
@setu1421
setu1421 / uploadfile
Created April 6, 2019 07:24
Upload each chunk
//Step 2: upload each chunk (this will run for every chunk unlike the other steps which are run once)
var uploadRequest = new UploadPartRequest
{
BucketName = bucketName,
Key = fileName,
UploadId = uploadId,
PartNumber = partNumber,
InputStream = ms,
IsLastPart = lastPart,
PartSize = ms.Length
@setu1421
setu1421 / gist:61f24898b5ccfe6232186ad66029e8c5
Last active April 6, 2019 07:19
Build and send a multi upload request
//Step 1: build and send a multi upload request
if (chunkIndex == 0)
{
var initiateRequest = new InitiateMultipartUploadRequest
{
BucketName = bucketName,
Key = fileName
};
var initResponse = _s3Client.InitiateMultipartUpload(initiateRequest);
@setu1421
setu1421 / UploadUtilityHelper.cs
Created April 6, 2019 06:41
Utility helper for uploading large files to AWS S3 bucket
public class UploadUtilityHelper
{
private readonly string bucketName = ConfigurationManager.AppSettings["BucketName"];
private static readonly RegionEndpoint bucketRegion = RegionEndpoint.USEast1;
public string UploadChunk(string fileName, string uploadId, int chunkIndex, int chunkMax, Stream stream, string prevETags)
{
var response = "";
try