1717package dlp .snippets ;
1818
1919// [START dlp_inspect_image_file]
20+
2021import com .google .cloud .dlp .v2 .DlpServiceClient ;
2122import com .google .privacy .dlp .v2 .ByteContentItem ;
2223import com .google .privacy .dlp .v2 .ByteContentItem .BytesType ;
2627import com .google .privacy .dlp .v2 .InspectConfig ;
2728import com .google .privacy .dlp .v2 .InspectContentRequest ;
2829import com .google .privacy .dlp .v2 .InspectContentResponse ;
29- import com .google .privacy .dlp .v2 .ProjectName ;
30+ import com .google .privacy .dlp .v2 .LocationName ;
3031import com .google .protobuf .ByteString ;
3132import java .io .FileInputStream ;
3233import java .util .ArrayList ;
@@ -47,9 +48,6 @@ public static void inspectImageFile(String projectId, String filePath) {
4748 // once, and can be reused for multiple requests. After completing all of your requests, call
4849 // the "close" method on the client to safely clean up any remaining background resources.
4950 try (DlpServiceClient dlp = DlpServiceClient .create ()) {
50- // Specify the project used for request.
51- ProjectName project = ProjectName .of (projectId );
52-
5351 // Specify the type and content to be inspected.
5452 ByteString fileBytes = ByteString .readFrom (new FileInputStream (filePath ));
5553 ByteContentItem byteItem =
@@ -70,7 +68,7 @@ public static void inspectImageFile(String projectId, String filePath) {
7068 // Construct the Inspect request to be sent by the client.
7169 InspectContentRequest request =
7270 InspectContentRequest .newBuilder ()
73- .setParent (project .toString ())
71+ .setParent (LocationName . of ( projectId , "global" ) .toString ())
7472 .setItem (item )
7573 .setInspectConfig (config )
7674 .build ();
0 commit comments