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?