# How to update ACL of binary file

**URL:** <https://forum.solidproject.org/t/how-to-update-acl-of-binary-file/5322>\
**Category:** Solid App Development FAQs\
**Created:** [June 3, 2022, 7:08pm UTC](https://forum.solidproject.org/t/how-to-update-acl-of-binary-file/5322 "2022-06-03T19:08:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hld0](https://avatars.discourse-cdn.com/v4/letter/h/85e7bf/32.png) [@hld0](https://forum.solidproject.org/u/hld0)\
**Post date:** [June 3, 2022, 7:08pm UTC](https://forum.solidproject.org/t/how-to-update-acl-of-binary-file/5322/1 "2022-06-03T19:08:01Z")

</div>

Hi Community!

We are building an app using the `inrupt/solid-client` library. Essentially I am trying to access a binary file’s ACL but I am failing so far to do so.

I’ve been loosely following [this](https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/manage-access-control-list/) tutorial, but I cannot manage to get it to work with arbitrary files.

When invoking

```javascript
await getSolidDatasetWithAcl(fileUrl);

```

The server responds with _“Error translating between RDF formats”_.

As of now, I am succeeding by invoking

```javascript
await getFileWithAcl(fileURL)

```

Now, for the feature I’m trying to implement I would like to manipulate a file’s ACL. Therefore, I’d like to use `createAclFromFallbackAcl` but to do so, I’d need a resource with the type `WithFallbackAcl & WithServerResourceInfo & WithAccessibleAcl`. Yet, I am somehow unable to combine all those methods to retrieve the correct dataset.

Does someone have an idea how I could go about doing this?

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Vincent](https://avatars.discourse-cdn.com/v4/letter/v/e9bcb4/32.png) [@Vincent](https://forum.solidproject.org/u/Vincent)\
**Post date:** [June 5, 2022, 12:33pm UTC](https://forum.solidproject.org/t/how-to-update-acl-of-binary-file/5322/2 "2022-06-05T12:33:15Z")

</div>

Generally, IIRC, you should be able to follow that tutorial, but replacing every instance of `SolidDataset` in a function call with `File`.

So for example, to take the code snippet from “Change Access to a Resource”, that would become something like this:

```javascript
import {
  getFileWithAcl,
  hasResourceAcl,
  hasAccessibleAcl,
  hasFallbackAcl,
  createAclFromFallbackAcl,
  getResourceAcl,
  setAgentResourceAccess,
  saveAclFor,
} from "@inrupt/solid-client";

async function test() {
  // Fetch the File and its associated ACLs, if available:
  const myFileWithAcl = await getFileWithAcl("https://example.com");
  
  // Obtain the File's own ACL, if available,
  // or initialise a new one, if possible:
  let resourceAcl;
  if (!hasResourceAcl(myFileWithAcl)) {
    if (!hasAccessibleAcl(myFileWithAcl)) {
      throw new Error(
        "The current user does not have permission to change access rights to this Resource."
      );
    }
    if (!hasFallbackAcl(myFileWithAcl)) {
      throw new Error(
        "The current user does not have permission to see who currently has access to this Resource."
      );
      // Alternatively, initialise a new empty ACL as follows,
      // but be aware that if you do not give someone Control access,
      // **nobody will ever be able to change Access permissions in the future** :
      // resourceAcl = createAcl(myFileWithAcl);
    }
    resourceAcl = createAclFromFallbackAcl(myFileWithAcl);
  } else {
    resourceAcl = getResourceAcl(myFileWithAcl);
  }
  
  // Give someone Control access to the given Resource:
  const updatedAcl = setAgentResourceAccess(
    resourceAcl,
    "https://example.com",
    { read: false, append: false, write: false, control: true }
  );
  
  // Now save the ACL:
  await saveAclFor(myFileWithAcl, updatedAcl);
}

```

(Here, `myFileWithAcl` is of type `WithServerResourceInfo`, and the function calls `hasAccessibleAcl()` and `hasFallbackAcl()` verify that it is also of types `WithAccessibleAcl` and `WithFallbackAcl`, respectively.)

---

<div class="post-metadata">

**Author:** ![hld0](https://avatars.discourse-cdn.com/v4/letter/h/85e7bf/32.png) [@hld0](https://forum.solidproject.org/u/hld0)\
**Post date:** [June 5, 2022, 2:17pm UTC](https://forum.solidproject.org/t/how-to-update-acl-of-binary-file/5322/3 "2022-06-05T14:17:35Z")

</div>

You are absolutely right.

I didn’t think that the `hasResourceAcl/hasAccessibleAcl` function calls were mandatory but, of course, they are.

That was the reason why I couldn’t get my program to run.

Thank you so much for your help!

---

<div class="post-metadata">

**Author:** ![ThisIsMissEm](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/thisismissem/32/3166_2.png) [@ThisIsMissEm](https://forum.solidproject.org/u/ThisIsMissEm)\
**Post date:** [June 9, 2022, 4:00pm UTC](https://forum.solidproject.org/t/how-to-update-acl-of-binary-file/5322/4 "2022-06-09T16:00:02Z")

</div>

You may also want to check out the Universal Access APIs: [Access Policies: Universal API — Inrupt JavaScript Client Libraries](https://docs.inrupt.com/developer-tools/javascript/client-libraries/tutorial/manage-access-policies/)
