2013-08-06 17 views

Odpowiedz

5

Załóż ważne konto Rackspace Utwórz nowy pojemnik, aby zapisać pliki potrzebne do utrzymania

public bool CreateNewContainer(string strContainerName) 
    { 
     bool isSuccess = false; 
     try 
     { 
      var cloudIdentity = new CloudIdentity() { APIKey = strAPIKey, Username = strUserName }; 
      var cloudFilesProvider = new CloudFilesProvider(cloudIdentity); 
      ObjectStore createContainerResponse = cloudFilesProvider.CreateContainer(strContainerName); 
      if (createContainerResponse == ObjectStore.ContainerCreated || createContainerResponse == ObjectStore.ContainerExists) 
      { 
       isSuccess = true; 
      } 
     } 
     catch (Exception) 
     { } 
     return isSuccess; 
    } 

Następnie zrób pojemnik publicznie dostępne poprzez ustawienie CDN Włączone

var cloudIdentity = new CloudIdentity() { APIKey = strAPIKey, Username = strUserName }; 
var cloudFilesProvider = new CloudFilesProvider(cloudIdentity); 
cloudFilesProvider.EnableCDNOnContainer(strContainerName, false); 

Get publiczny adres URL pojemnika

var cloudIdentity = new CloudIdentity() { APIKey = strAPIKey, Username = strUserName }; 
      var cloudFilesProvider = new CloudFilesProvider(cloudIdentity); 
      ContainerCDN strCdnURL = cloudFilesProvider.GetContainerCDNHeader(strContainerName); 
      string returnURL = strCdnURL.CDNUri 

Następnie użyj tego adresu URL i nazwy pliku, aby uzyskać dostęp do pliku publicznie.

+0

Dziękujemy za szybką i trafną odpowiedź. –

Powiązane problemy