gpt4 book ai didi

java - Google Drive Api [将文件上传到未在浏览器中显示的服务帐户]

转载 作者:行者123 更新时间:2023-11-30 08:53:34 26 4
gpt4 key购买 nike

<分区>

我正在使用 java google drive api 上传文件。我的问题是上传文件后我没有从我的谷歌驱动器中找到上传的文件。我怎样才能在网络浏览器中看到这些文件。有什么想法请帮助我吗?

我的java代码是:

    HttpTransport httpTransport = new NetHttpTransport();
JsonFactory jsonFactory = new JacksonFactory();

try {
GoogleCredential credential = new GoogleCredential.Builder().setTransport(httpTransport).setJsonFactory(jsonFactory).setServiceAccountId(IRingeeConstants.SERVICE_ACCOUNT_EMAIL)
.setServiceAccountScopes(Collections.singleton(DriveScopes.DRIVE)).setServiceAccountPrivateKeyFromP12File(new java.io.File("G:\\Ringee-1a1f1b786226.p12")).build();

Drive service = new Drive.Builder(httpTransport, jsonFactory, credential).setApplicationName(IRingeeConstants.APPLICATION_NAME).build();

printAbout(service);

File body = new File();
body.setTitle("ringeeprofileimage");
body.setDescription("ringeeapp");
body.setMimeType("application/vnd.google-apps.folder");

java.io.File fileContent = new java.io.File("G:\\document.txt");
FileContent mediaContent = new FileContent("text/plain", fileContent);

File file = service.files().insert(body, mediaContent).execute();
System.out.print("file id is :" + file.getId());

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com