GCS에 이미지를 업로드 한 다음 동일한 파일 이름 (image.png)으로 다른 이미지로 덮어 씁니다. GCS 브라우저에서 이미지를 덮어 쓰는 것을 볼 수 있지만 (다른 크기, 타임 스탬프) getServingUrl()을 사용하여 이미지의 URL을 가져 오려고하면 처음 업로드 한 이미지의 URL이 나타납니다 !!!Google 클라우드 저장소 - 이전 이미지의 URL을 제공하는 getServingUrl()
새 파일 이름 (image2.png)으로 이미지를 추가하면 새 URL이 나타납니다. 이 이미지를 다른 이미지로 덮어 쓰면 (image2.png라는 이름으로 유지) 원래의 image2.png URL이 다시 나타납니다.
String bucketName = "my_bucket_name";
String userFileName = "image.png";
try {
GcsFileOptions instance = GcsFileOptions.getDefaultInstance();
GcsFilename fileName = new GcsFilename(bucketName, userFileName);// getFileName(request);
GcsOutputChannel outputChannel;
gcsService.delete(fileName);
outputChannel = gcsService.createOrReplace(fileName, instance);
copy(request.getInputStream(), Channels.newOutputStream(outputChannel));
} catch (IOException e) {
System.out.println(e.getMessage());
}
ImagesService imagesService = ImagesServiceFactory.getImagesService();
String url = imagesService.getServingUrl(ServingUrlOptions.Builder.withGoogleStorageFileName("/gs/" +
bucketName + "/" + userFileName).secureUrl(true));
사람이 내가 여기 잃었는지 말해 주시겠습니까 : 여기
내 코드? 새로 업로드 된 이미지의 핸들을 제공하기 위해 ImagesService를 얻는 방법은 무엇입니까? 감사. java_geek 당신을 지적
자바 대신 PHP를 사용하면이 게시물을 참조 할 수 있습니다. http://stackoverflow.com/questions/37646849/how-can -we-use-firebase-image-file-and-resize-them-get-serving-url/37673504 # 37673504 –