我正在使用this template将文件上传到GDrive:
File fileMetadata = new File();
fileMetadata.setName("My Report");
fileMetadata.setMimeType("application/vnd.google-apps.spreadsheet");
java.io.File filePath = new java.io.File("files/report.csv");
FileContent mediaContent = new FileContent("text/csv", filePath);
File file = driveService.files().create(fileMetadata, mediaContent)
.setFields("id")
.execute();
System.out.println("File ID: " + file.getId());
我尝试使用Google表格API并发送更新语言区域的请求:
List<Request> requests = Collections.singletonList(
new Request().setUpdateSpreadsheetProperties(
new UpdateSpreadsheetPropertiesRequest()
.setFields("locale")
.setProperties(
new SpreadsheetProperties()
.setLocale("en_US")
)
)
);
BatchUpdateSpreadsheetRequest requestBody = new BatchUpdateSpreadsheetRequest();
requestBody.setRequests(requests);
requestBody.setIncludeSpreadsheetInResponse(false);
Sheets.Spreadsheets.BatchUpdate updateLocaleRequest = sheets.spreadsheets().batchUpdate(spreadsheetId, requestBody);
BatchUpdateSpreadsheetResponse response = updateLocaleRequest.execute();
但我想在上传文件时设置区域设置。