question: @ Override public void offerData ( String id , Address us , Address them , String localUri , Map < String , String > headers ) throws IOException { long length = - 1 ; String hash = null ; File fileLocal = new File ( localUri ) ; if ( fileLocal . exists ( ) ) { length = fileLocal . length ( ) ; if ( length > MAX_TRANSFER_LENGTH ) { throw new IOException ( "Length too large: " + length ) ; } FileInputStream is = new FileInputStream ( fileLocal ) ; hash = sha1sum ( is ) ; is . close ( ) ; } else { java . io . File fileExtern = new java . io . File ( localUri ) ; length = fileExtern . length ( ) ; if ( length > MAX_TRANSFER_LENGTH ) { throw new IOException ( "Length too large: " + length ) ; } java . io . FileInputStream is = new java . io . FileInputStream ( fileExtern ) ; hash = sha1sum ( is ) ; is . close ( ) ; } if ( headers == null ) headers = new HashMap < > ( ) ; headers . put ( "File-Name" , fileLocal . getName ( ) ) ; headers . put ( "File-Length" , String . valueOf ( length ) ) ; headers . put ( "File-Hash-SHA1" , hash ) ; if ( ! headers . containsKey ( "Mime-Type" ) ) { String mimeType = SystemServices . getMimeType ( localUri ) ; headers . put ( "Mime-Type" , mimeType ) ; } String [ ] paths = localUri . split ( "/" ) ; String url = URI_PREFIX_OTR_IN_BAND + SystemServices . sanitize ( paths [ paths . length - 1 ] ) ; Request request = new Request ( "OFFER" , us , them , url , headers ) ; offerCache . put ( url , new Offer ( id , localUri , request ) ) ; sendRequest ( request ) ; }
target:  private File writeDataToStorage (String url, byte[] data) { debug( "writeDataToStorage:" + url + " " + data.length); String[] path = url.split("/"); String sanitizedPath = SystemServices.sanitize(path[path.length - 1]); File fileDownloadsDir = new File(Environment.DIRECTORY_DOWNLOADS); fileDownloadsDir.mkdirs(); info.guardianproject.iocipher.File file = new info.guardianproject.iocipher.File(fileDownloadsDir, sanitizedPath); debug( "writeDataToStorage:" + file.getAbsolutePath() ); try { OutputStream output = (new info.guardianproject.iocipher.FileOutputStream(file)); output.write(data); output.flush(); output.close(); return file; } catch (IOException e) { OtrDebugLogger.log("error writing file", e); return null; } }