Is there a solution how to get the link of the photo from firebase storage only java, not android?
I have -
FileInputStream serviceAccount = new
FileInputStream("./serviceAccountKey.json");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(serviceAccount))
.setStorageBucket("g-app-af0af.appspot.com")
.build();
FirebaseApp.initializeApp(options);
Bucket bucket = StorageClient.getInstance().
bucket("g-app-af0af.appspot.com");
I can upload photos
InputStream testFile = new FileInputStream("./12.png");
String blobString = "test_folder/" + "12.png";
Blob blob = bucket.create(blobString, testFile, "image/png",
Bucket.BlobWriteOption.userProject("g-app-af0af"));
I can get the link but it’s temporary and I need the eternal !!!
String bucketName = "g-app-af0af.appspot.com";
String blobName = "test_folder/12.png";
String keyPath = "./serviceAccountKey.json";
URL signedUrl = blob.getStorage().signUrl(BlobInfo.newBuilder(bucketName,
blobName).build(),
14, TimeUnit.SECONDS,
Storage.SignUrlOption.signWith(ServiceAccountCredentials.fromStream(
new FileInputStream(keyPath))));
System.out.println(signedUrl);
I can delete and download it is good
Blob blob1 = bucket.getStorage().get(BlobId.of(bucketName, blobName));
blob1.downloadTo(Paths.get("./zz.png"));
bucket.getStorage().delete(bucketName, blobName,
Storage.BlobSourceOption.userProject("g-app-af0af"));
But I can't get a permanent url link to the photo from storage, Well, in principle, as an option, specify 100,000 days thanks for the help
So that I can do it))