public async Task <dynamic> UploadObject([FromForm] Model.InputModel input)
        {
            // save the file on the server
            var fileSavePath = Path.Combine(_env.ContentRootPath, input.fileToUpload.FileName);

            using (var stream = new FileStream(fileSavePath, FileMode.Create))
                await input.fileToUpload.CopyToAsync(stream);
            ObjectsApi objects = new ObjectsApi();

            // get the bucket...
            //dynamic oauth = await OAuthController.GetInternalAsync();
            //objects.Configuration.AccessToken = oauth.access_token;
            objects.Configuration.AccessToken = objCredentials.TokenInternal;

            // upload the file/object, which will create a new object
            dynamic uploadedObj;

            using (StreamReader streamReader = new StreamReader(fileSavePath))
            {
                uploadedObj = await objects.UploadObjectAsync(input.bucketKey,
                                                              input.fileToUpload.FileName, (int)streamReader.BaseStream.Length, streamReader.BaseStream, sModelDatatype);
            }

            // cleanup
            System.IO.File.Delete(fileSavePath);

            return(uploadedObj);
        }
Ejemplo n.º 2
0
 public void Post(Model.InputModel value)
 {
     Debug.WriteLine("Validação ok");
 }