|
1 | | -package moadong.media.util; |
2 | | - |
3 | | -import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; |
4 | | -import com.google.api.client.json.jackson2.JacksonFactory; |
5 | | -import com.google.api.services.drive.Drive; |
6 | | -import com.google.api.services.drive.DriveScopes; |
7 | | -import com.google.auth.http.HttpCredentialsAdapter; |
8 | | -import com.google.auth.oauth2.GoogleCredentials; |
9 | | -import java.io.InputStream; |
10 | | -import java.util.Collections; |
11 | | -import org.springframework.beans.factory.annotation.Value; |
12 | | -import org.springframework.context.annotation.Bean; |
13 | | -import org.springframework.context.annotation.Configuration; |
14 | | -import org.springframework.util.ResourceUtils; |
15 | | - |
16 | | -@Configuration |
17 | | -public class GoogleDriveConfig { |
18 | | - |
19 | | - @Value("${spring.cloud.gcp.credentials.location}") |
20 | | - private String credentialsLocation; |
21 | | - |
22 | | - @Value("${google.application.name}") |
23 | | - private String applicationName; |
24 | | - |
25 | | - @Bean |
26 | | - public Drive googleDriveService() throws Exception { |
27 | | - InputStream in = ResourceUtils.getURL(credentialsLocation).openStream(); |
28 | | - GoogleCredentials credentials = GoogleCredentials.fromStream(in) |
29 | | - .createScoped(Collections.singleton(DriveScopes.DRIVE)); |
30 | | - |
31 | | - return new Drive.Builder( |
32 | | - GoogleNetHttpTransport.newTrustedTransport(), |
33 | | - JacksonFactory.getDefaultInstance(), |
34 | | - new HttpCredentialsAdapter(credentials)) |
35 | | - .setApplicationName(applicationName) |
36 | | - .build(); |
37 | | - |
38 | | - } |
39 | | - |
40 | | - |
41 | | -} |
| 1 | +//package moadong.media.util; |
| 2 | +// |
| 3 | +//import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; |
| 4 | +//import com.google.api.client.json.jackson2.JacksonFactory; |
| 5 | +//import com.google.api.services.drive.Drive; |
| 6 | +//import com.google.api.services.drive.DriveScopes; |
| 7 | +//import com.google.auth.http.HttpCredentialsAdapter; |
| 8 | +//import com.google.auth.oauth2.GoogleCredentials; |
| 9 | +//import java.io.InputStream; |
| 10 | +//import java.util.Collections; |
| 11 | +//import org.springframework.beans.factory.annotation.Value; |
| 12 | +//import org.springframework.context.annotation.Bean; |
| 13 | +//import org.springframework.context.annotation.Configuration; |
| 14 | +//import org.springframework.util.ResourceUtils; |
| 15 | +// |
| 16 | +//@Configuration |
| 17 | +//public class GoogleDriveConfig { |
| 18 | +// |
| 19 | +// @Value("${spring.cloud.gcp.credentials.location}") |
| 20 | +// private String credentialsLocation; |
| 21 | +// |
| 22 | +// @Value("${google.application.name}") |
| 23 | +// private String applicationName; |
| 24 | +// |
| 25 | +// @Bean |
| 26 | +// public Drive googleDriveService() throws Exception { |
| 27 | +// InputStream in = ResourceUtils.getURL(credentialsLocation).openStream(); |
| 28 | +// GoogleCredentials credentials = GoogleCredentials.fromStream(in) |
| 29 | +// .createScoped(Collections.singleton(DriveScopes.DRIVE)); |
| 30 | +// |
| 31 | +// return new Drive.Builder( |
| 32 | +// GoogleNetHttpTransport.newTrustedTransport(), |
| 33 | +// JacksonFactory.getDefaultInstance(), |
| 34 | +// new HttpCredentialsAdapter(credentials)) |
| 35 | +// .setApplicationName(applicationName) |
| 36 | +// .build(); |
| 37 | +// |
| 38 | +// } |
| 39 | +// |
| 40 | +// |
| 41 | +//} |
0 commit comments