I'm trying to upload a PDF file to Firebase Storage using the Firebase Admin SDK in Eclipse Java. I have been referring to this doc: https://cloud.google.com/storage/docs/uploading-objects#storage-upload-object-java . So far, it seemed like I was able to upload the file BUT the pdf content seems to be damaged somehow as the size(as shown in Firebase Storage) is smaller(11 bytes) as compared to the original size(3028 bytes). So I tried to download the file and as it turns out, I am not able to open the downloaded file. I have implemented the following code:
BlobId blobId = BlobId.of(bucket, folder+"/"+blobName);
System.out.println("Blob Id:"+blobId);
BlobInfo blobInfo = BlobInfo
.newBuilder(blobId)
.setContentType("application/pdf")
.build();
System.out.println("Blob Info:"+blobInfo);
Blob blob = storage.create(blobInfo, blobName.getBytes(UTF_8));
System.out.println("BLOB:"+blob);
I'm not really able to get much info about uploading PDF from the Admin side. I'm guessing blobName.getBytes(UTF_8)
might be the issue somehow. Any help appreciated!