google-cloud-node: options.public to storage/File.createWriteStream doesn't make uploaded files public

According to API docs, storage/File.createWriteStream should take a boolean option public that makes the uploaded file publicly readable. However, in my experience this isn’t the case.

I create the stream like this:

let cloudFileStream = cloudFile.createWriteStream({
  public: true,
  resumable: false,
})

And still, I have to call cloudFile.makePublic after the upload has finished, because otherwise the file is only accessible to the owner:

cloudFileStream
  .on('finish', () => {
    cloudFile.makePublic()
  })

Environment details

  • OS: OS X El Capitan
  • Node.js version: 6.4.0
  • npm version: 3.10.6
  • google-cloud-node version: 0.39.0

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 17 (15 by maintainers)

Most upvoted comments

I would like to resolve this the right way once and for all! I’m going to need some help from @jgeewax, @omaray, maybe @capstan. Simply put, what needs to be in an upload request body that makes the file being uploaded public? Thanks!

@stephenplusplus OK, so that should mean that predefinedAcl: publicRead is equivalent to calling file.makePublic() does it not? I end up with the same in my file permissions, by calling file.makePublic().

@stephenplusplus How did you add the allusers: Reader bit? Does this correspond to predefinedAcl: publicRead?