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 
<https://cloud.google.com/storage/docs/uploading-objects#storage-upload-object-code-sample>,
 
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?



-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-appengine+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-appengine/e11dab31-5fd7-467b-8043-07a28b999feeo%40googlegroups.com.
  • [google-appengin... 전하정
    • [google-app... 'Katayoon (Cloud Platform Support)' via Google App Engine

Reply via email to