Re: [gs-discussion] Written file not showing up in Google Cloud Storage

309 views
Skip to first unread message

Google Cloud Storage Team

unread,
Mar 18, 2013, 4:09:39 PM3/18/13
to gs-discussion
Hello Sevak,

To view the files with a browser based tool, we use a different url: https://storage.cloud.google.com/.  That will work for you if you have a default project configured, or you can go to the apis console https://code.google.com/apis/console/, visit the "Cloud Storage" tab, and follow the link to the online browser.  That link will automatically fill in a parameter for your project ID.  

If that is what you are already doing, and you're still not seeing your objects show up, can you replicate your results with the gsutil tool? If so, please send me the output of the relevant gsutil commands (likely cp and ls) with the -DD flag enabled so I can take a closer look at what's going on.

For prototyping, using gsutil is a great way to get going fast.  Because it's written in house and we know the code well, reproducing issues with gsutil is the fastest path to a resolution. 

Best Regards,
Benson
Google Cloud Storage Team


On Sat, Mar 16, 2013 at 2:57 PM, Sevak Asadorian <sasad...@gmail.com> wrote:
I write to my bucket using the following code:

String result = "Done writing file.";

try {
// Get the file service
FileService fileService = FileServiceFactory.getFileService();

GSFileOptionsBuilder optionsBuilder = new GSFileOptionsBuilder()
 .setBucket("maple")
 .setKey("hello.txt")
 .setAcl("public-read");

// Create your object
AppEngineFile writableFile = fileService.createNewGSFile(optionsBuilder.build());
// Open a channel for writing
boolean lockForWrite = false; // Do you want to exclusively lock this object?
FileWriteChannel writeChannel = fileService.openWriteChannel(writableFile, lockForWrite);
// For this example, we write to the object using the PrintWriter
PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel, "UTF8"));
out.println("The woods are lovely and deep.");
out.println("But I have promises too keep.");

// Close the object without finalizing.
out.close();

// Save the file path
String path = writableFile.getFullPath();

// Lock the file so no one else can access it at the same time
lockForWrite = true;

// Write to the unfinalized file again in a separate request
writableFile = new AppEngineFile(path);
writeChannel = fileService.openWriteChannel(writableFile, lockForWrite);
writeChannel.write(ByteBuffer.wrap("And miles to go before I sleep.".getBytes()));

// Finalize the object
writeChannel.closeFinally();
}
catch (IOException e) {
result = "Failed to read file";
e.printStackTrace();
}
return result;

I am also able to read the file using java code. However, when I access the Google Cloud Storage using my browser, I don't see the newly written file in my bucket. why is this?
Also, when i try the link to the file (http://storage.googleapis.com/maple/hello.txt) i get the following:

<Error>
<Code>NoSuchKey</Code>
<Message>The specified key does not exist.</Message>
</Error>


Please advise.

--
You received this message because you are subscribed to the Google Groups "Google Cloud Storage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gs-discussio...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages