public override JToken GetInfoForFolders(Server server, string folder) { // Retrieve folders from server. Uri uri = PanoramaUtil.GetContainersUri(server.URI, folder, true); // Not L10N using (WebClient webClient = new WebClient()) { webClient.Headers.Add(HttpRequestHeader.Authorization, server.AuthHeader); string folderInfo = webClient.UploadString(uri, PanoramaUtil.FORM_POST, string.Empty); return(JObject.Parse(folderInfo)); } }
public override JToken GetInfoForFolders(Server server, string folder) { EnsureLogin(server); // Retrieve folders from server. Uri uri = PanoramaUtil.GetContainersUri(server.URI, folder, true); using (var webClient = new WebClientWithCredentials(server.URI, server.Username, server.Password)) { return(webClient.Get(uri)); } }
public FolderState IsValidFolder(string folderPath, string username, string password) { try { var uri = PanoramaUtil.GetContainersUri(ServerUri, folderPath, false); using (var webClient = new WebClient()) { webClient.Headers.Add(HttpRequestHeader.Authorization, Server.GetBasicAuthHeader(username, password)); var folderInfo = webClient.UploadString(uri, PanoramaUtil.FORM_POST, string.Empty); // Not L10N JToken response = JObject.Parse(folderInfo); // User needs write permissions to publish to the folder if (!PanoramaUtil.CheckFolderPermissions(response)) { return(FolderState.nopermission); } // User can only upload to a TargetedMS folder type. if (!PanoramaUtil.CheckFolderType(response)) { return(FolderState.notpanorama); } } } catch (WebException ex) { var response = ex.Response as HttpWebResponse; if (response != null && response.StatusCode == HttpStatusCode.NotFound) { return(FolderState.notfound); } else { throw; } } return(FolderState.valid); }
public FolderState IsValidFolder(string folderPath, string username, string password) { try { var uri = PanoramaUtil.GetContainersUri(ServerUri, folderPath, false); using (var webClient = new WebClientWithCredentials(ServerUri, username, password)) { JToken response = webClient.Get(uri); // User needs write permissions to publish to the folder if (!PanoramaUtil.CheckFolderPermissions(response)) { return(FolderState.nopermission); } // User can only upload to a TargetedMS folder type. if (!PanoramaUtil.CheckFolderType(response)) { return(FolderState.notpanorama); } } } catch (WebException ex) { var response = ex.Response as HttpWebResponse; if (response != null && response.StatusCode == HttpStatusCode.NotFound) { return(FolderState.notfound); } else { throw; } } return(FolderState.valid); }