2

How to write to a static resource (text file) in a Managed package

In my developer org, I can read and write a static resource file by a visualforce page. I make a managed package of them, then install the managed package into another scratch org, there is no write permission of the static resource file any more. Please help.

1 Answer 1

4

Static Resources are not subscriber-editable, i.e., cannot be changed in subscriber orgs when installed as part of a managed package.

Static Resources are meant to be just that - static. They are not for dynamic file storage. If your managed package needs to store writeable document blobs you should store them somewhere else, most likely a ContentDocument.

4
  • Thanks David, I may put the same file into the ContantDocument. Do I need a specific URL for visualforce page and LWC to access the "ContentDocument" of my file?
    – user88696
    Commented Sep 28, 2020 at 13:55
  • You'd probably want to be querying and retrieving the content, but I don't have much insight into your use case.
    – David Reed
    Commented Sep 28, 2020 at 19:41
  • Thanks David, Is there a simple example to retrieve the file and write back to the file through a visualforce page and lightning component.
    – user88696
    Commented Sep 29, 2020 at 9:04
  • I've never seen such an example but it's really not complicated; just make sure to read up on the Content data structures
    – David Reed
    Commented Sep 29, 2020 at 14:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .