コード例 #1
0
    @Override
    public ArrayList<String> execute() throws JSONException, IOException, SpikaException {
      String tmppath =
          CameraCropActivity.this.getExternalCacheDir() + "/" + Const.TMP_BITMAP_FILENAME;

      String fileId = CouchDB.uploadFile(filePath);

      Bitmap originalBitmap = BitmapFactory.decodeFile(filePath);
      Bitmap thumbBitmap =
          Utils.scaleBitmap(originalBitmap, Const.PICTURE_THUMB_SIZE, Const.PICTURE_THUMB_SIZE);
      Utils.saveBitmapToFile(thumbBitmap, tmppath);
      String thumbFileId = CouchDB.uploadFile(tmppath);

      ArrayList<String> list = new ArrayList<String>();
      list.add(fileId);
      list.add(thumbFileId);

      return list;
    }
コード例 #2
0
 public void encode(File file, OutputStream base64OutputStream) {
   try {
     InputStream is = new FileInputStream(file);
     OutputStream out = new Base64OutputStream(base64OutputStream, 0);
     Utils.copyStream(is, out);
     is.close();
     out.close();
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }