本文整理汇总了C#中net.openstack.Providers.Rackspace.CloudFilesProvider类的典型用法代码示例。如果您正苦于以下问题:C# CloudFilesProvider类的具体用法?C# CloudFilesProvider怎么用?C# CloudFilesProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CloudFilesProvider类属于net.openstack.Providers.Rackspace命名空间,在下文中一共展示了CloudFilesProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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());
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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>");
}