Мне нужно установить некоторые метаданные (тип контента и кодировку контента) для каждого файла.
Я могу сделать это с помощью версии 1.x (ниже пример), но не в новой версии
Код: Выделить всё
MultipleFileUpload upload = tm.uploadDirectory(
bucket,
prefix,
filePath.toFile(),
true,
(file, metadata) -> {
String mimeType = "application/json";
try {
mimeType = Files.probeContentType(Paths.get(file.toURI()));
if (mimeType == null) {
if (file.getAbsolutePath().contains("bulkdata")) {
mimeType = "application/octet-stream";
}
if (file.getAbsolutePath().contains(".raw")) {
mimeType = "application/octet-stream";
}
if (file.getAbsolutePath().contains("frames")) {
mimeType = "multipart/related";
}
if (file.getAbsolutePath().contains("thumbnail")) {
mimeType = "image/jpeg";
}
}
} catch (Exception ex) {
mimeType = "application/octet-stream";
}
if (file.getName().endsWith(".gz")) {
metadata.setContentEncoding("gzip");
mimeType = "application/json";
}
metadata.setContentType(mimeType);
}
);
Подробнее здесь: https://stackoverflow.com/questions/768 ... d-metadata