Hi everyone,
I'm very confused about what do I have to do to migrate from the now deprecated Files API to GCS Client Library. Before anything I'd like to
express my complete dissatisfaction with the fact that I have to manage a second service from now on just to write files on the server. Anyway, let's stick to the problem:
I have this piece of code which is working very well for years:FileService fileService = FileServiceFactory.getFileService();
AppEngineFile file = fileService.createNewBlobFile("text/plain");
FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
Writer writer = Channels.newWriter(writeChannel, "UTF8");
//write my file
writeChannel.closeFinally();
BlobKey blobKey = fileService.getBlobKey(file);
//I got my BlobKey and I'm happy
But FileService is now deprecated. When I try to use the GCS client library (after discovering that the library isn't part of the GAE SDK just to make me even more "happy"), I got this situation:
GcsService gcsService = GcsServiceFactory.createGcsService(); //no problems
GcsFilename gcsFileName = new GcsFilename(bucketName, objectName); //I have to create this object to create the file below
gcsService.createOrReplace(gcsFileName, gcsFileOptions); //I really miss the day when file.createNewFile(); was sufficient
The problem is the second line. As it seems now I have to provide a file name. Ok, I can gerente a random one, just to keep the API satisfied. Now the problem is the "bucket name". I don't even know what it means. I just want to save a file.
After searching a bit I found that it is something related to the Google Cloud Storage service. Ok, let's signup another service, accept another terms, and so on (... and I just want to save a file). When logging on the
Cloud Console, I can see my App Engine project, with the following options: App Engine (which links to the
App Engine Dashboard), BigQuery (not using) and Cloud Datastore (which links to a view of my stored entities). No Cloud Storage. Following this
activation guide, I have to create another project (!!!).
So no Cloud Storage dashboard or console anywhere, nowhere to configure or get that "bucket name" and no, I'm not going to drop my 2-years project to create another one just to enable file writing.
What do I have to do to just-save-a-file on the server? Why is that so hard?
Thank you.
(Sorry for the text but I'm really upset with this situation)