GAE standard project cannot upload files to GCS bucket

60 views
Skip to first unread message

전하정

unread,
Jul 20, 2020, 6:11:30 PM7/20/20
to Google App Engine
Hi. I'm trying to make a website that allows users to upload files from their local file system to the website. I'm now implementing API for uploading files to the GCS bucket.

I used the code from Google docs, which was very helpful. This code worked pretty well when I run my project on a local server(localhost:8080), however, when I deployed my project to GAE and run again({my-project-id}.appspot.com), it returns java.nio.file.NoSuchFileException.

I think the problem is that GAE server cannot read any file path from local computer, such as C:/users/desktop/test.txt, but I think I need path like this because I have to make users upload their files from their own computer.

Here is the code that I used:

    Storage storage = StorageOptions.newBuilder().setProjectId(projectId).build().getService();
    BlobId blobId = BlobId.of(uploadReqDto.getBucketName(), uploadReqDto.getUploadFileName());
    BlobInfo blobInfo = BlobInfo.newBuilder(blobId).build();
    storage.create(blobInfo, Files.readAllBytes(Paths.get(uploadReqDto.getLocalFileLocation())));

uploadReqDto.getBucketName(),  uploadReqDto.getUploadFileName() and uploadReqDto.getLocalFileLocation() are request parameters for the POST API, which looks like:


{
  "bucketName": "myBucketName",
  "uploadFileName": "Test1.txt",
  "localFileLocation": "C:/users/desktop/my/file/path"
}

Is there any special way to configure paths from local computer when the project is deployed and running on GAE?



Katayoon (Cloud Platform Support)

unread,
Jul 21, 2020, 12:40:56 PM7/21/20
to Google App Engine
Hi,

It seems you have posted your question on Stack Overflow and your question is answered there

Note that, Google groups are reserved for general questions about Google Cloud Platform-end products and for technical questions, we recommend to post it on Stack Overflow
Reply all
Reply to author
Forward
0 new messages