public GetUploadLocationResponse Post(GetUploadLocationRequest request) { _log.StartLog(request); try { var contName = "deletable" + Guid.NewGuid().ToString("D").ToLowerInvariant(); var container = _azure.CreateContainerIfDoesNotExist(contName); var blobPolicy = new SharedAccessBlobPolicy { Permissions = SharedAccessBlobPermissions.Read | SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.List, SharedAccessExpiryTime = DateTimeOffset.Now.AddHours(HOURS_FILE_SHOULD_BE_ACCESSIBLE) }; var permissions = new BlobContainerPermissions(); permissions.SharedAccessPolicies.Add("mypolicy", blobPolicy); permissions.PublicAccess = BlobContainerPublicAccessType.Container; container.SetPermissions(permissions); var sharedAccessSignature = container.GetSharedAccessSignature("mypolicy"); return new GetUploadLocationResponse {Name= container.Name, Location = container.Uri.ToString(), Sas = sharedAccessSignature, Account = _azure.Account}; } catch (Exception e) { _log.Fatal("error", e); Errors.Add(e.Message + " " + e.StackTrace); return new GetUploadLocationResponse {Errors = Errors}; } }
public GetUploadLocationResponse Post(GetUploadLocationRequest request) { _log.StartLog(request); try { var contName = "deletable" + Guid.NewGuid().ToString("D").ToLowerInvariant(); var container = _azure.CreateContainerIfDoesNotExist(contName); var blobPolicy = new SharedAccessBlobPolicy { Permissions = SharedAccessBlobPermissions.Read | SharedAccessBlobPermissions.Write | SharedAccessBlobPermissions.List, SharedAccessExpiryTime = DateTimeOffset.Now.AddHours(HOURS_FILE_SHOULD_BE_ACCESSIBLE) }; var permissions = new BlobContainerPermissions(); permissions.SharedAccessPolicies.Add("mypolicy", blobPolicy); permissions.PublicAccess = BlobContainerPublicAccessType.Container; container.SetPermissions(permissions); var sharedAccessSignature = container.GetSharedAccessSignature("mypolicy"); return(new GetUploadLocationResponse { Name = container.Name, Location = container.Uri.ToString(), Sas = sharedAccessSignature, Account = _azure.Account }); } catch (Exception e) { _log.Fatal("error", e); Errors.Add(e.Message + " " + e.StackTrace); return(new GetUploadLocationResponse { Errors = Errors }); } }