119 |
119 |
public Uri StorageUrl { get; set; }
|
120 |
120 |
|
121 |
121 |
|
122 |
|
public Uri RootAddressUri { get; set; }
|
|
122 |
public Uri RootAddressUri
|
|
123 |
{
|
|
124 |
get { return _rootAddressUri; }
|
|
125 |
set { _rootAddressUri = value; }
|
|
126 |
}
|
123 |
127 |
|
124 |
128 |
|
125 |
129 |
public double DownloadPercentLimit { get; set; }
|
... | ... | |
138 |
142 |
|
139 |
143 |
BufferManager _bufferManager=BufferManager.CreateBufferManager(TreeHash.DEFAULT_BLOCK_SIZE*4,(int)TreeHash.DEFAULT_BLOCK_SIZE);
|
140 |
144 |
private string _userCatalogUrl;
|
|
145 |
private Uri _rootAddressUri;
|
141 |
146 |
|
142 |
147 |
public CloudFilesClient(string userName, string apiKey)
|
143 |
148 |
{
|
... | ... | |
167 |
172 |
_userCatalogUrl = "https://pithos.okeanos.io/user_catalogs";
|
168 |
173 |
//Get the root address (StorageUrl without the account)
|
169 |
174 |
var storageUrl = StorageUrl.AbsoluteUri;
|
170 |
|
//var usernameIndex = storageUrl.LastIndexOf(UserName);
|
171 |
|
//var rootUrl = storageUrl.Substring(0, usernameIndex);
|
172 |
|
// RootAddressUri = new Uri(rootUrl);
|
173 |
|
RootAddressUri = new Uri(storageUrl);
|
|
175 |
var usernameIndex = storageUrl.LastIndexOf(UserName);
|
|
176 |
var rootUrl = storageUrl.Substring(0, usernameIndex);
|
|
177 |
RootAddressUri = new Uri(rootUrl);
|
|
178 |
//RootAddressUri = new Uri(storageUrl);
|
174 |
179 |
|
175 |
180 |
var httpClientHandler = new HttpClientHandler
|
176 |
181 |
{
|
... | ... | |
234 |
239 |
authClient.DefaultRequestHeaders.Add("X-Auth-User", UserName);
|
235 |
240 |
authClient.DefaultRequestHeaders.Add("X-Auth-Key", ApiKey);
|
236 |
241 |
|
237 |
|
string storageUrl;
|
|
242 |
|
238 |
243 |
string token;
|
|
244 |
string objectStorageService;
|
239 |
245 |
|
240 |
246 |
//using (var response = await authClient.GetAsyncWithRetries(new Uri(VersionPath, UriKind.Relative),3).ConfigureAwait(false)) // .DownloadStringWithRetryRelative(new Uri(VersionPath, UriKind.Relative), 3);
|
241 |
247 |
using (var response = await authClient.SendAsyncWithRetries(new HttpRequestMessage(HttpMethod.Post,new Uri("", UriKind.Relative)), 3).ConfigureAwait(false))
|
... | ... | |
245 |
251 |
var body=await response.Content.ReadAsStringAsync();
|
246 |
252 |
JObject json = (JObject) JsonConvert.DeserializeObject(body);
|
247 |
253 |
dynamic jsonD = json;
|
248 |
|
|
249 |
|
storageUrl = json["access"]["serviceCatalog"][6]["endpoints"][0]["publicURL"].ToString();
|
250 |
|
if (String.IsNullOrWhiteSpace(storageUrl))
|
|
254 |
|
|
255 |
objectStorageService = json["access"]["serviceCatalog"][6]["endpoints"][0]["publicURL"].ToString();
|
|
256 |
if (String.IsNullOrWhiteSpace(objectStorageService))
|
251 |
257 |
throw new InvalidOperationException("Failed to obtain storage url");
|
252 |
258 |
|
253 |
259 |
token = this.ApiKey;// response.Headers.GetFirstValue(TOKEN_HEADER);
|
... | ... | |
255 |
261 |
throw new InvalidOperationException("Failed to obtain token url");
|
256 |
262 |
}
|
257 |
263 |
|
|
264 |
string storageUrl = new Uri(objectStorageService).Combine(UserName).ToString();
|
258 |
265 |
_baseClient = new RestClient
|
259 |
266 |
{
|
260 |
267 |
BaseAddress = storageUrl,
|
... | ... | |
266 |
273 |
Token = token;
|
267 |
274 |
|
268 |
275 |
//Get the root address (StorageUrl without the account)
|
269 |
|
//var usernameIndex=storageUrl.LastIndexOf(UserName);
|
270 |
|
var rootUrl = storageUrl;//.Substring(0, usernameIndex);
|
|
276 |
var rootUrl = objectStorageService;//.Substring(0, usernameIndex);
|
271 |
277 |
RootAddressUri = new Uri(rootUrl);
|
272 |
278 |
|
273 |
279 |
|