You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 16, 2022. It is now read-only.
I tried reading the file in memory with openReadChannel method, but I get this error
java.io.FileNotFoundException: com.google.appengine.tools.cloudstorage.dev.LocalRawGcsService@1dc2b580: No such file: GcsFilename(my_bucket, hmgtHXafqTDbYkY6XkfWNw)
I also tried getting the file metadata with getMetadata method, but the GcsFileMetadata object is null
Is the uploadUrl flow fully integrated with the local GcsService object?
Does it work only on online environment?
The text was updated successfully, but these errors were encountered:
While I wait for an answer, I temporary solved the problem using this workaround.
I load the file in memory using BlobstoreService and then write it back using GcsService, like follows:
private void localhostCopyFile(FileInfo fileInfo, GcsFilename destinationFile) throws IOException {
if (SystemProperty.Environment.Value.Development == SystemProperty.environment.value()) {
LOG.info("File " + fileInfo.getGsObjectName() + " will be copied");
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
BlobKey blobKey = blobstoreService.createGsBlobKey(fileInfo.getGsObjectName());
LOG.info("BlobKey: " + blobKey);
// Read file in memory
byte[] data = blobstoreService.fetchData(blobKey, 0, fileInfo.getSize());
// Code copied from https://cloud.google.com/appengine/docs/java/googlecloudstorageclient/app-engine-cloud-storage-sample#writing_a_file_to_cloud_storage
GcsFileOptions instance = GcsFileOptions.getDefaultInstance();
GcsOutputChannel outputChannel = GCS_SERVICE.createOrReplace(destinationFile, instance);
// copy() method available from https://github.com/GoogleCloudPlatform/appengine-gcs-client/blob/master/java/example/src/main/java/com/google/appengine/demos/GcsExampleServlet.java
copy(new ByteArrayInputStream(data), Channels.newOutputStream(outputChannel));
// Optional, remove the original uploaded file
blobstoreService.delete(blobKey);
} else {
// Production environment, nothing to do here
}
}
Because this is only for local dev-server, I'm not using big files (only small test files) so loading the entire file in memory is not a blocking issue.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Using App Engine SDK 1.9.48 with Maven project and this library
I implementing a flow which will use an upload-url generated like this
The generated url is something like this
http://localhost:8888/_ah/upload/aghhcGUtYmFzZXIiCxIVX19CbG9iVXBsb2FkU2Vzc2lvbl9fGICAgICAgMAJDA
The callback is implemented like this
The
toString()
of the file object, is like thisI tried reading the file in memory with
openReadChannel
method, but I get this errorI also tried getting the file metadata with
getMetadata
method, but theGcsFileMetadata
object is nullIs the
uploadUrl
flow fully integrated with the localGcsService
object?Does it work only on online environment?
The text was updated successfully, but these errors were encountered: