本文整理汇总了C#中net.openstack.Providers.Rackspace.CloudFilesProvider类的典型用法代码示例。如果您正苦于以下问题:C# CloudFilesProvider类的具体用法?C# CloudFilesProvider怎么用?C# CloudFilesProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudFilesProvider类属于net.openstack.Providers.Rackspace命名空间,在下文中一共展示了CloudFilesProvider类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
Console.WriteLine();
if (ParseArguments(args))
{
DirectoryInfo directory = null;
try
{
directory = new DirectoryInfo(Source);
if (!directory.Exists)
{
throw new Exception(String.Format("Source directory does not exist\n{0}", Source));
}
}
catch (Exception ex)
{
PrintException(ex);
}
Console.WriteLine(String.Format("Source directory: {0}", Source));
Console.WriteLine(String.Format("Destination container: {0}", Container));
Console.WriteLine("Logging in...");
Console.WriteLine();
if (Login())
{
var cloudFiles = new CloudFilesProvider(auth);
try
{
switch (cloudFiles.CreateContainer(Container))
{
case ObjectStore.ContainerCreated:
case ObjectStore.ContainerExists:
foreach (var file in directory.GetFiles())
{
Console.WriteLine(String.Format("{0,3:0}% Uploading: {1}", 0, file.Name));
cloudFiles.CreateObjectFromFile(Container, file.FullName, progressUpdated: delegate(long p)
{
Console.SetCursorPosition(0, Console.CursorTop -1);
Console.WriteLine(String.Format("{0,3:0}% Uploading: {1}", ((float)p / (float)file.Length) * 100, file.Name));
});
}
break;
default:
throw new Exception(String.Format("Unknown error when creating container {0}", Container));
}
}
catch (Exception ex)
{
PrintException(ex);
}
}
}
Console.WriteLine();
Console.Write("Press any key to exit");
Console.ReadKey();
}
开发者ID:jonwalton,项目名称:cloud_code_samples,代码行数:60,代码来源:Program.cs
示例2: Should_Return_Container_List_With_Internal_Url
public void Should_Return_Container_List_With_Internal_Url()
{
var provider = new CloudFilesProvider();
var containerList = provider.ListContainers(useInternalUrl:true, identity: _testIdentity);
Assert.IsNotNull(containerList);
Assert.IsTrue(containerList.Any());
}
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:8,代码来源:CloudFilesTests.cs
示例3: Should_Return_Container_List
public void Should_Return_Container_List()
{
var provider = new CloudFilesProvider();
var containerList = provider.ListContainers(identity: _testIdentity);
Assert.IsNotNull(containerList);
Assert.IsTrue(containerList.Any());
}
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:8,代码来源:CloudFilesTests.cs
示例4: CFProvidersCreateContainer
protected void CFProvidersCreateContainer(string cfcreatecontainername, string dcregion, bool dcsnet = true)
{
var identity = new RackspaceCloudIdentity() { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };
CloudIdentityProvider identityProvider = new net.openstack.Providers.Rackspace.CloudIdentityProvider(identity);
CloudFilesProvider CloudFilesProvider = new net.openstack.Providers.Rackspace.CloudFilesProvider(identity);
var CfCreateContainer = CloudFilesProvider.CreateContainer(cfcreatecontainername, dcregion, dcsnet);
}
开发者ID:ravikamachi,项目名称:OpenStackDotNet-Test,代码行数:9,代码来源:CloudFiles.aspx.cs
示例5: CFProvidersCreateObjectFromFile
protected void CFProvidersCreateObjectFromFile(string cfcontainername, string cfcreateobjfilepath, string cfcreateobjfilename, int cfcreateobjchunksize, string dcregion, bool dcsnet = true)
{
var identity = new RackspaceCloudIdentity() { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };
CloudIdentityProvider identityProvider = new net.openstack.Providers.Rackspace.CloudIdentityProvider(identity);
CloudFilesProvider CloudFilesProvider = new net.openstack.Providers.Rackspace.CloudFilesProvider(identity);
CloudFilesProvider.CreateObjectFromFile(cfcontainername, cfcreateobjfilepath, cfcreateobjfilename, cfcreateobjchunksize, null, dcregion, null, dcsnet);
}
开发者ID:ravikamachi,项目名称:OpenStackDotNet-Test,代码行数:9,代码来源:CloudFiles.aspx.cs
示例6: CFProvidersDeleteContainerObject
protected void CFProvidersDeleteContainerObject(string cfcontainername, string cfdeletecontainerobject, string dcregion, bool dcsnet = true)
{
var identity = new RackspaceCloudIdentity() { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };
CloudIdentityProvider identityProvider = new net.openstack.Providers.Rackspace.CloudIdentityProvider(identity);
CloudFilesProvider CloudFilesProvider = new net.openstack.Providers.Rackspace.CloudFilesProvider(identity);
var Cfdeletecontainerobject = CloudFilesProvider.DeleteObject(cfcontainername, cfdeletecontainerobject, null, dcregion, dcsnet);
}
开发者ID:ravikamachi,项目名称:OpenStackDotNet-Test,代码行数:9,代码来源:CloudFiles.aspx.cs
示例7: CloudFilesContainerNode
public CloudFilesContainerNode(CloudFilesProvider provider, Container container, ContainerCDN containerCdn)
{
if (provider == null)
throw new ArgumentNullException("provider");
if (container == null)
throw new ArgumentNullException("container");
_provider = provider;
_container = container;
_containerCdn = containerCdn;
}
开发者ID:rackerlabs,项目名称:rax-vsix,代码行数:11,代码来源:CloudFilesContainerNode.cs
示例8: CloudFilesTests
public CloudFilesTests(ITestOutputHelper testLog)
{
var testOutput = new XunitTraceListener(testLog);
Trace.Listeners.Add(testOutput);
OpenStackNet.Tracing.Http.Listeners.Add(testOutput);
var authenticationProvider = TestIdentityProvider.GetIdentityProvider();
authenticationProvider.Authenticate();
_cloudFiles = new CloudFilesProvider(null, authenticationProvider);
}
开发者ID:ravikamachi,项目名称:openstack.net,代码行数:11,代码来源:CloudFilesProviderTests.cs
示例9: CloudFilesObjectNode
public CloudFilesObjectNode(CloudFilesProvider provider, Container container, ContainerObject containerObject)
{
if (provider == null)
throw new ArgumentNullException("provider");
if (container == null)
throw new ArgumentNullException("container");
if (containerObject == null)
throw new ArgumentNullException("containerObject");
_provider = provider;
_container = container;
_containerObject = containerObject;
}
开发者ID:rackerlabs,项目名称:rax-vsix,代码行数:13,代码来源:CloudFilesObjectNode.cs
示例10: CFProviderListContainers
protected void CFProviderListContainers(string dcregion, bool dcsnet = true)
{
var identity = new RackspaceCloudIdentity() { Username = CFUsernameText.Text, APIKey = CFApiKeyText.Text };
CloudIdentityProvider identityProvider = new net.openstack.Providers.Rackspace.CloudIdentityProvider(identity);
CloudFilesProvider CloudFilesProvider = new net.openstack.Providers.Rackspace.CloudFilesProvider(identity);
var CfContainers = CloudFilesProvider.ListContainers(null, null, null, dcregion, dcsnet);
CFContainerDDL.DataSource = CfContainers;
CFContainerDDL.DataTextField = "Name";
CFContainerDDL.DataBind();
}
开发者ID:ravikamachi,项目名称:OpenStackDotNet-Test,代码行数:13,代码来源:CloudFiles.aspx.cs
示例11: ListContainer
private IEnumerable<ContainerObject> ListContainer(CloudIdentity cloudIdentity, string container, int? limit = null, string prefix = null, string region = null, bool useInternalUrl = false) {
var provider = new CloudFilesProvider(cloudIdentity);
ContainerObject lastContainerObject = null;
do {
string marker = lastContainerObject != null ? lastContainerObject.Name : null;
IEnumerable<ContainerObject> containerObjects = provider.ListObjects(container, limit, marker, null, prefix, region, useInternalUrl, cloudIdentity);
lastContainerObject = null;
foreach (ContainerObject containerObject in containerObjects) {
lastContainerObject = containerObject;
yield return containerObject;
}
} while (lastContainerObject != null);
}
开发者ID:pjcunningham,项目名称:SwiftClient.Net,代码行数:16,代码来源:Provider.cs
示例12: DownloadFromRackSpaceCloudFiles
public bool DownloadFromRackSpaceCloudFiles()
{
bool syncSucceeded = true;
try
{
var cloudIdentity = new CloudIdentity() { APIKey = this.apiKey, Username = this.username };
var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
IEnumerable<ContainerObject> containerObjectList = cloudFilesProvider.ListObjects(container);
foreach (ContainerObject containerObject in containerObjectList)
{
cloudFilesProvider.GetObjectSaveToFile(container, localSource, containerObject.Name, containerObject.Name);
}
}
catch (Exception e)
{
Console.WriteLine("Exception in downloading from rackspace: " + e);
syncSucceeded = false;
}
return syncSucceeded;
}
开发者ID:smosgin,项目名称:labofthings,代码行数:21,代码来源:RackspaceCloudFilesSynchronizer.cs
示例13: RackspaceCloudFilesSynchronizer
public RackspaceCloudFilesSynchronizer(RemoteInfo ri, string container, SynchronizeDirection syncDirection)
{
this.disposed = false;
this.username = ri.accountName;
this.apiKey = ri.accountKey;
this.syncDirection = syncDirection;
this.container = container;
try
{
var cloudIdentity = new CloudIdentity() { APIKey = this.apiKey, Username = this.username };
var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
ObjectStore createContainerResponse = cloudFilesProvider.CreateContainer(container);// assume default region for now
if (!createContainerResponse.Equals(ObjectStore.ContainerCreated) && !createContainerResponse.Equals(ObjectStore.ContainerExists))
Console.WriteLine("Container creation failed! Response: " + createContainerResponse.ToString());
}
catch (Exception e)
{
Console.WriteLine("Exception in creating container: " + e);
}
}
开发者ID:smosgin,项目名称:labofthings,代码行数:21,代码来源:RackspaceCloudFilesSynchronizer.cs
示例14: Authenticate
//Method to Authenticate the credentials and obtain token
public void Authenticate()
{
try
{
//Creating an instance of CloudIdentityProvider providing the CloudIdentity object and urls in the constructor
provider = new CloudIdentityProvider(identity, "https://identity.api.rackspacecloud.com/v1.0", "https://lon.identity.api.rackspacecloud.com/v1.0");
//Calling the authenticate method which returns an UserAccess object containing token and user details
UserAccess access = provider.Authenticate(identity);
token = access.Token;
userdetails = access.User;
//Set the TokenId property
TokenId = token.Id;
//Verify with other programmers to make this method void
cloudFiles = new CloudFilesProvider(identity);
//return token.Id;
}
catch (UserAuthenticationException ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
catch (UserAuthorizationException ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
catch (UserNotAuthorizedException ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
}
开发者ID:vcholan,项目名称:generic-cloud-storage-client,代码行数:41,代码来源:Rackspace.cs
示例15: CKEditorUpload
public ActionResult CKEditorUpload(string CKEditorFuncNum)
{
var m = new AccountModel();
string baseurl = null;
if (Request.Files.Count == 0)
return Content("");
var file = Request.Files[0];
var fn = $"{DbUtil.Db.Host}.{DateTime.Now:yyMMddHHmm}.{m.CleanFileName(Path.GetFileName(file.FileName))}";
var error = string.Empty;
var rackspacecdn = ConfigurationManager.AppSettings["RackspaceUrlCDN"];
if (rackspacecdn.HasValue())
{
baseurl = rackspacecdn;
var username = ConfigurationManager.AppSettings["RackspaceUser"];
var key = ConfigurationManager.AppSettings["RackspaceKey"];
var cloudIdentity = new CloudIdentity {APIKey = key, Username = username};
var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
cloudFilesProvider.CreateObject("AllFiles", file.InputStream, fn);
}
else // local server
{
baseurl = $"{Request.Url.Scheme}://{Request.Url.Authority}/Upload/";
try
{
var path = Server.MapPath("/Upload/");
path += fn;
path = m.GetNewFileName(path);
file.SaveAs(path);
}
catch (Exception ex)
{
error = ex.Message;
baseurl = string.Empty;
}
}
return Content($"<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction( {CKEditorFuncNum}, '{baseurl + fn}', '{error}' );</script>");
}
开发者ID:stevesloka,项目名称:bvcms,代码行数:39,代码来源:AccountController.cs
示例16: FroalaUpload
public ActionResult FroalaUpload(HttpPostedFileBase file)
{
var m = new AccountModel();
string baseurl = null;
var fn = $"{DbUtil.Db.Host}.{DateTime.Now:yyMMddHHmm}.{m.CleanFileName(Path.GetFileName(file.FileName))}";
var error = string.Empty;
var rackspacecdn = ConfigurationManager.AppSettings["RackspaceUrlCDN"];
if (rackspacecdn.HasValue())
{
baseurl = rackspacecdn;
var username = ConfigurationManager.AppSettings["RackspaceUser"];
var key = ConfigurationManager.AppSettings["RackspaceKey"];
var cloudIdentity = new CloudIdentity {APIKey = key, Username = username};
var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
cloudFilesProvider.CreateObject("AllFiles", file.InputStream, fn);
}
else // local server
{
baseurl = $"{Request.Url.Scheme}://{Request.Url.Authority}/Upload/";
try
{
var path = Server.MapPath("/Upload/");
path += fn;
path = m.GetNewFileName(path);
file.SaveAs(path);
}
catch (Exception ex)
{
error = ex.Message;
baseurl = string.Empty;
}
}
return Json(new {link = baseurl + fn, error}, JsonRequestBehavior.AllowGet);
}
开发者ID:GSBCfamily,项目名称:bvcms,代码行数:37,代码来源:AccountController.cs
示例17: UploadToRackSpaceCloudFiles
public bool UploadToRackSpaceCloudFiles()
{
bool syncSucceeded = true;
try
{
var cloudIdentity = new CloudIdentity() { APIKey = this.apiKey, Username = this.username };
var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
List<string> fileList = AmazonS3Helper.ListFiles(localSource);
foreach (string file in fileList)
{
cloudFilesProvider.CreateObjectFromFile(container, file, Path.GetFileName(file));
// assuming this overwrites file if it exists.
}
}
catch (Exception e)
{
Console.WriteLine("Exception in uploading to rackspace: "+e);
syncSucceeded = false;
}
return syncSucceeded;
}
开发者ID:donnaknew,项目名称:programmingProject,代码行数:24,代码来源:RackspaceCloudFilesSynchronizer.cs
示例18: Should_Get_MetaData_For_Account
public void Should_Get_MetaData_For_Account()
{
var provider = new CloudFilesProvider();
var accountHeadersResponse = provider.GetAccountMetaData(identity: _testIdentity);
Assert.IsNotNull(accountHeadersResponse);
Assert.IsTrue(accountHeadersResponse.ContainsKey("Temp-Url-Key"));
}
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:9,代码来源:CloudFilesTests.cs
示例19: Should_Copy_Object_When_Not_Passing_Content_Length
public void Should_Copy_Object_When_Not_Passing_Content_Length()
{
var provider = new CloudFilesProvider();
var copyResponse = provider.CopyObject(sourceContainerName, sourceObjectName, destinationContainerName, destinationObjectName, identity: _testIdentity);
Assert.AreEqual(ObjectStore.ObjectCreated, copyResponse);
}
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:7,代码来源:CloudFilesTests.cs
示例20: Should_Copy_Object_When_Passing_Content_Length
public void Should_Copy_Object_When_Passing_Content_Length()
{
Dictionary<string, string> header = new Dictionary<string, string>();
header.Add(CloudFilesProvider.ContentLength, "62504");
var provider = new CloudFilesProvider();
var copyResponse = provider.CopyObject(sourceContainerName, sourceObjectName, destinationContainerName, destinationObjectName, header, identity: _testIdentity);
Assert.AreEqual(ObjectStore.ObjectCreated, copyResponse);
}
开发者ID:Dan-Pallone-II,项目名称:openstack.net,代码行数:10,代码来源:CloudFilesTests.cs
注:本文中的net.openstack.Providers.Rackspace.CloudFilesProvider类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论