I’m trying to call the get method from the asset canister and I’m getting the following error:
Uncaught (in promise) Error: Call failed:
Canister: ryjl3-tyaaa-aaaaa-aaaba-cai
Method: get (query)
"Status": "rejected"
"Code": "CanisterError"
"Message": "IC0503: Canister ryjl3-tyaaa-aaaaa-aaaba-cai trapped explicitly: no such encoding"
I am using the following code:
export const getJpg = async (key): Promise<{ content: Array<number>; sha256: [] | [Array<number>]; content_type: string; content_encoding: string; total_length: bigint }> => {
const authClient = await AuthClient.create();
const identity = await authClient.getIdentity();
const agent = new HttpAgent({
identity,
});
await agent.fetchRootKey();
const store: _SERVICE = Actor.createActor(idlFactory, {
agent: agent,
canisterId,
});
return store.get({key: key, accept_encodings: [""]})
}
I didn’t provide encoding when uploading by chunks in the following post.
Hey all,
I’m coding up the ability for a user to upload a picture in my app. I think I coded the chunking function correctly but I’m running into access errors?
Uncaught (in promise) Error: Call was rejected:
Request ID: 8bb18dfb85d58fbbdf41d29833ebe0e4a61a19c51f6401323e42f2b651333d4d
Reject code: 4
Reject text: Caller is not authorized
My code Looks like so
const encodeArrayBuffer = (file) => Array.from(new Uint8Array(file));
const MAX_CHUNK_SIZE = 1024 * 500; // 500kb
async function…
Does anyone have any insight into what encoding I am supposed to add or what I am doing wrong?
I found this but don’t think it helps other than suggest that @roman-kashitsyn might know how to address your problem.
dfinity:main
← levifeldman:levi/let-store-and-serve-files-without-a-content_encoding
opened 03:57AM - 07 Dec 21 UTC
Before this commit, the canister could store a file with a content-encoding: "" … , but it returned a 404 not found when asked for it.
This commit does this by a simple one-line change, line-673.
This commit also trims the leading and trailing whitespace of every content_encoding string stored with the files for the consistency.
Hah yeah that would make sense I never gave it encoding
With which encoding the file was uploaded, with that encoding you need to request it. By default, dfx uploads files with identity
encoding. Try this store.get({key: key, accept_encodings: ["identity"]})
I recommend that you familiarize yourself with this certified_assets canister source code in detail
And I think that such a functionality will be useful in your project