I want to store this file in firebase storage , this file is pdf file i have created and it now downloading into my phone directory/file manager, but i want store it on firebase storage as well/ too....
What I have tried:
private void creatPdf(String Name1, String father_n1, String id_n1, String mob_n1, String dist_sp1, String police_sp1, String crime_sp1, String date_i1, String time_i1, String detail_i1, String address_p1 ) throws FileNotFoundException, URISyntaxException {
String pdfPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).toString();
File file = new File(pdfPath, System.currentTimeMillis()+".pdf");
OutputStream outputStream = new FileOutputStream(file);
PdfWriter writer = new PdfWriter(file);
PdfDocument pdfDocument = new PdfDocument(writer);
Document document = new Document(pdfDocument);
pdfDocument.setDefaultPageSize(PageSize.A4);
document.setTopMargin(5);
Drawable drawable = getDrawable(R.drawable.logo);
Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap();
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] bitmapData = stream.toByteArray();
ImageData imageData = ImageDataFactory.create(bitmapData);
Image image = new Image(imageData);
image.setHeight(100);
image.setWidth(100);
image.scaleToFit(100, 100);
image.setHorizontalAlignment(HorizontalAlignment.CENTER);
Paragraph firText = new Paragraph("First Information Report").setBold().setFontSize(19).setTextAlignment(TextAlignment.CENTER);
float[] width = {100f , 100f};
Table table = new Table(width);
table.setHorizontalAlignment(HorizontalAlignment.CENTER);
table.addCell(new Cell().add(new Paragraph("Name")));
table.addCell(new Cell().add(new Paragraph(Name1)));
table.addCell(new Cell().add(new Paragraph("Father Name")));
table.addCell(new Cell().add(new Paragraph(father_n1)));
table.addCell(new Cell().add(new Paragraph("CNIC Number")));
table.addCell(new Cell().add(new Paragraph(id_n1)));
table.addCell(new Cell().add(new Paragraph("Mobile Number")));
table.addCell(new Cell().add(new Paragraph(mob_n1)));
table.addCell(new Cell().add(new Paragraph("Present Address")));
table.addCell(new Cell().add(new Paragraph(address_p1)));
table.addCell(new Cell().add(new Paragraph("District")));
table.addCell(new Cell().add(new Paragraph(dist_sp1)));
table.addCell(new Cell().add(new Paragraph("Police Station")));
table.addCell(new Cell().add(new Paragraph(police_sp1)));
table.addCell(new Cell().add(new Paragraph("Nature of Crime")));
table.addCell(new Cell().add(new Paragraph(crime_sp1)));
table.addCell(new Cell().add(new Paragraph("Date of Incident")));
table.addCell(new Cell().add(new Paragraph(date_i1)));
table.addCell(new Cell().add(new Paragraph("Time of Incident")));
table.addCell(new Cell().add(new Paragraph(time_i1)));
float[] width1 = {940f , 360f};
Table table1 = new Table(width1);
table1.setHorizontalAlignment(HorizontalAlignment.CENTER);
table1.addCell(new Cell(90, 90).add(new Paragraph("Detail of Incident")));
table1.addCell(new Cell().add(new Paragraph(detail_i1)));
BarcodeQRCode QRCode = new BarcodeQRCode(Name1+"\n"+father_n1+"\n"+id_n1+"\n"+mob_n1+"\n"+address_p1+"\n"+
dist_sp1+"\n"+police_sp1+"\n"+crime_sp1+"\n"+date_i1+"\n"+time_i1+"\n"+detail_i1);
PdfFormXObject qrCodeObject = QRCode.createFormXObject(ColorConstants.BLACK, pdfDocument);
Image qrImage = new Image(qrCodeObject).setWidth(80).setHorizontalAlignment(HorizontalAlignment.CENTER);
document.add(image);
document.add(firText);
document.add(table);
document.add(table1);
document.add(qrImage);
document.close();
Toast.makeText(FIRActivity.this, "FIR Registered, check pdf file", Toast.LENGTH_SHORT).show();
}