как загрузить изображения в ведро движка приложения из пружины - PullRequest
0 голосов
/ 19 октября 2018

Я пытался загрузить изображения в ведро app-engine, из контроллера весенней загрузки, аналогично приведенному ниже коду.но не работает, когда проверено почтальоном.

@RestController
@RequestMapping("/api")
public class UploadingController {
@RequestMapping(method = RequestMethod.POST, value = "/imageUpload")
@SuppressWarnings("deprecation")
public String uploadImages(Part filePart) throws IOException {

String bucketName = "mcqimages";
    DateTimeFormatter dtf = DateTimeFormat.forPattern("-YYYY-MM-dd-HHmmssSSS");
    DateTime dt = DateTime.now(DateTimeZone.UTC);
    String dtString = dt.toString(dtf);
    final String fileName = filePart.getSubmittedFileName() + dtString;

 // the inputstream is closed by default, so we don't need to close it here
    BlobInfo blobInfo =
        storage.create(
            BlobInfo
            .newBuilder(bucketName, fileName)
            // Modify access list to allow all users with link to read file
            .setAcl(new ArrayList < > (Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER))))
            .build(),
            filePart.getInputStream());
    // return the public download link
    return blobInfo.getMediaLink();
}
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...