boolean downloadBlob(CAttrValue value) { String fName = makeFileName(value); String url = value.m_strValue; int nQuest = url.lastIndexOf('?'); if (nQuest > 0) { url += "&"; } else { url += "?"; } url += "client_id=" + getSync().getClientID(); try{ NetResponse resp = getNet().pullFile(url, fName, getSync(), null); if (!resp.isOK()) { getSync().stopSync(); m_nErrCode = RhoAppAdapter.getErrorFromResponse(resp); return(false); } }catch (Exception exc) { m_nErrCode = RhoAppAdapter.getNetErrorCode(exc); throw exc; } value.m_strValue = CFilePath.getRelativePath(fName, CRhodesApp.getRhoRootPath()); return(true); }
//public static IDBResult createResult(){ // return getInstance().m_dbStorage.createResult(); //} public String makeBlobFolderName() { String fName = CFilePath.join(CRhodesApp.getRhoRootPath(), "db/db-files"); CRhoFile.recursiveCreateDir(fName); return(fName); }
public NetResponse pullFile(String strUrl, String strFileName, IRhoSession oSession, Hashtable <String, String> headers) { NetResponse resp = null; m_isPullFile = true; m_bCancel = false; try{ if (!strFileName.startsWith("file:")) { try{ strFileName = CFilePath.join(CRhodesApp.getRhoRootPath(), strFileName); } catch (IOException e) { LOG.ERROR("getDirPath failed.", e); } } m_pulledFile = RhoClassFactory.createFile(); m_pulledFile.open(strFileName, CRhoFile.EOpenModes.OpenForReadWrite); m_pulledFile.setPosTo(m_pulledFile.size()); do { resp = doRequest("GET", strUrl, null, oSession, headers, m_pulledFile.size()); }while(!m_bCancel && (resp == null || resp.isOK()) && m_nCurDownloadSize > 0); }finally{ if (m_pulledFile != null) { try { m_pulledFile.close(); } catch (IOException e) { LOG.ERROR("file closing failed.", e); } m_pulledFile = null; } } copyHashtable(m_OutHeaders, headers); m_isPullFile = false; m_nCurDownloadSize = 0; return(resp != null && !m_bCancel ? resp : makeResponse("", Convert.ToInt32(HttpStatusCode.InternalServerError))); }