public static String getFile(String deviceId, String fileFullPath) { int extLength = fileFullPath.Length - fileFullPath.LastIndexOf("."); String fileExt = fileFullPath.Substring(fileFullPath.LastIndexOf("."), extLength); JSONRequestIndex reqMsg = new JSONRequestIndex(deviceId, fileFullPath); JSONMessageWrapper msgWrapper = new JSONMessageWrapper("getFile", reqMsg.request()); try { String response = HttpClient.GET("getFile", msgWrapper.getMessage()); if (!string.IsNullOrEmpty(response)) { byte[] filebytes = Convert.FromBase64String(response); Guid gid = Guid.NewGuid(); FileStream fs = new FileStream(TEMP_LOCATION + gid + fileExt, FileMode.CreateNew, FileAccess.Write, FileShare.None); fs.Write(filebytes, 0, filebytes.Length); fs.Close(); return TEMP_LOCATION + gid.ToString() + fileExt; } return ""; } catch (WebException e) { //return Device Not Found return "DNF"; } }
public static ArrayList getIndexObject(String deviceId, String dir) { JSONRequestIndex reqMsg = new JSONRequestIndex(deviceId, dir); JSONMessageWrapper msgWrapper = new JSONMessageWrapper("getIndex", reqMsg.request()); String response = HttpClient.GET("getIndex", msgWrapper.getMessage()); return Parser.parseIndexes(response); }