Multipart upload to appengine

前端 未结 1 1940
轮回少年
轮回少年 2021-01-07 14:15

I\'m having multiple problems with appengine (java/jersey), but now I\'m stucked with uploading files via multipart.

I\'ve read this answer: https://stackoverflow.co

1条回答
  •  隐瞒了意图╮
    2021-01-07 14:59

    You have to use Blobstore for uploading.

    Call blobstoreService.createUploadUrl to create an upload URL for the form that the user will fill out, passing the application path to load when the POST of the form is completed.

    
        
    " method="post" enctype="multipart/form-data">

    and then in servlet:

    Map> blobs = blobstoreService.getUploads(req);
    List blobKeys = blobs.get("myFile");
    

    You can upload files to Storage directly, but passing UploadOptions to .createUploadUrl:

    UploadOptions options = new UploadOptions.Builder().withGoogleStorageBucketName("mybucket");
    String uploadUrl = blobstoreService.createUploadUrl("/upload", options)
    

    Follow documentation https://cloud.google.com/appengine/docs/java/blobstore/#Java_Uploading_a_blob

    0 讨论(0)
提交回复
热议问题