Skip to content

options.public to storage/File.createWriteStream doesn't make uploaded files public #1566

Description

@aknuds1

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

Activity

  1. stephenplusplus commented on Sep 6, 2016

    @stephenplusplus
    Contributor

    Setting public: true will set the object's predefinedAcl to publicRead. Calling file.makePublic() will grant the READER role to allUsers. Do you have any existing rules that might be trumping the predefinedAcl?

    To test, I created a new bucket and new file, so that no existing configuration could get in the way.

    The bucket's permissions:
    screen shot 2016-09-06 at 9 05 39 am

    The bucket's default object permissions:
    screen shot 2016-09-06 at 9 05 58 am

    The bucket's contents:
    screen shot 2016-09-06 at 9 06 25 am

    The file's permissions:
    screen shot 2016-09-06 at 9 06 46 am

  2. aknuds1 commented on Sep 6, 2016

    @aknuds1
    ContributorAuthor

    @stephenplusplus So, the only issue here should be an existing rule trumping predefinedAcl? Am not aware of having any such rule, but I'll look.

  3. aknuds1 commented on Sep 6, 2016

    @aknuds1
    ContributorAuthor

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

  4. stephenplusplus commented on Sep 6, 2016

    @stephenplusplus
    Contributor

    Yes, that came from setting predefinedAcl: publicRead.

    @jgeewax, am I giving out correct information?

  5. aknuds1 commented on Sep 6, 2016

    @aknuds1
    ContributorAuthor

    @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().

  6. Splaktar commented on Sep 18, 2016

    @Splaktar
    Contributor

    We saw this same issue lately as well. We used the CLI (since the UI didn't have this feature) to change the predefinedAcl on the whole bucket since we didn't want to call file.makePublic() on every file.

    It would be ideal if the option worked as expected and make the file public.

  7. stephenplusplus commented on Sep 19, 2016

    @stephenplusplus
    Contributor

    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!

  8. aknuds1 commented on Sep 19, 2016

    @aknuds1
    ContributorAuthor

    @stephenplusplus Come to think of it, how would you write a test for this issue? Apparently it's not solved, so seems as if you lack a test for this functionality.

  9. stephenplusplus commented on Sep 19, 2016

    @stephenplusplus
    Contributor
  10. aknuds1 commented on Sep 19, 2016

    @aknuds1
    ContributorAuthor

    @stephenplusplus I guess there's some sort of false positive there, looks that way at least.

  11. stephenplusplus commented on Sep 19, 2016

    @stephenplusplus
    Contributor

    Indeed, looking forward to fixing this :)

  12. Capstan commented on Sep 19, 2016

    @Capstan

    @stephenplusplus When you upload an object, you can specify either a predefined ACL or a fully-enumerated ACL, and you get errors if you have both. If you don't want to bother writing client logic, you could just always turn public: true to the predefined ACL but then also use whatever client-provided ACL and let the service return the error that you cannot cross the streams. Seems like a bad idea to have the client specify one ACL that doesn't set it to public read and another in the same request that does. Or perhaps I'm misunderstanding and there's no additional user-provided ACL?

  13. stephenplusplus commented on Sep 19, 2016

    @stephenplusplus
    Contributor

    We're not really running into conflicting ACL specifications during the upload here. In the simplest case, a user might want to upload a file and make it public in one line, and it would look like this:

    bucket.upload('./localfile.txt', { public: true }, function(err) {})

    That would send POST https://.../o?name=localfile.txt&predefinedAcl=publicRead.

    Is this what our library should do, or is there more to it?

  14. Capstan commented on Sep 19, 2016

    @Capstan

    I presume there's no body to the POST if resumable and it also contains an uploadType URL parameter that's either media or resumable? If so, then, that's exactly what it should do. Does the ACL you get back from such an object not list allUsers: READER?

  15. 1 remaining item

  16. stephenplusplus commented on Oct 3, 2016

    @stephenplusplus
    Contributor

    It seems like we're doing this right as far as the API is concerned. If I'm missing something, we'll re-open and get back to work. Thanks!

  17. Splaktar commented on Oct 12, 2016

    @Splaktar
    Contributor

    Sorry, I ran out of bandwidth to debug this and then Hurricane Matthew hit. We were able to work around it for now. Thanks.

  18. added a commit that references this issue on Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

api: storageIssues related to the Cloud Storage API.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions