Пример #1
0
        public async Task <UploadOperation> UploadObjectAsync(Bucket bucket, string targetPath, UploadOptions uploadOptions, byte[] bytesToUpload, CustomMetadata customMetadata, bool immediateStart = true)
        {
            var uploadOptionsSWIG = uploadOptions.ToSWIG();

            SWIG.UploadResult uploadResult = await Task.Run(() => SWIG.storj_uplink.upload_object(_access._project, bucket.Name, targetPath, uploadOptionsSWIG));

            UploadOperation upload = new UploadOperation(bytesToUpload, uploadResult, targetPath, customMetadata);

            if (immediateStart)
            {
                upload.StartUploadAsync(); //Don't await it, otherwise it would "block" UploadObjectAsync
            }
            return(upload);
        }
Пример #2
0
        public async Task <UploadOperation> UploadObjectAsync(Bucket bucket, string targetPath, UploadOptions uploadOptions, Stream stream, CustomMetadata customMetadata, bool immediateStart)
        {
            var uploadOptionsSWIG = uploadOptions.ToSWIG();

            _uploadOptions.Add(uploadOptionsSWIG);

            using (SWIG.UplinkUploadResult uploadResult = await Task.Run(() => SWIG.storj_uplink.uplink_upload_object(_access._project, bucket.Name, targetPath, uploadOptionsSWIG)).ConfigureAwait(false))
            {
                UploadOperation upload = new UploadOperation(stream, uploadResult, targetPath, customMetadata);
                if (immediateStart)
                {
                    upload.StartUploadAsync(); //Don't await it, otherwise it would "block" UploadObjectAsync
                }
                return(upload);
            }
        }