public byte[] getAsBytes() {
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            DataOutputStream dos = new DataOutputStream(baos);
            dos.write(postHash);
            dos.write(parentHash);
            
            dos.writeUTF(new Gson().toJson(this.postInfo));
            
            if (this.attachData == null) {
                dos.writeUTF(""); // There is no attachment
            } else {
                this.attachData.writeToStream(dos);
            }
            
            return baos.toByteArray();
        } catch (IOException ex) {
            Logger.getLogger(NanoPost.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        return null;
    }