1

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.

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.

| improve this answer | |
  • 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 Sep 28 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 Sep 28 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 Sep 29 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 Sep 29 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.