I have implmented the file storing logic in backend for uploading files on canister, i am able to upload the files but not getting the correct link for the uploaded file

we can just directly upload files without needing to enter any other fields:
https://esygv-biaaa-aaaak-ak2va-cai.icp0.io/
in conosle can check the uploaded file link , but its not showing the file

can check files uploaded in list_assets
backend:DFINITY Canister Candid UI

code
frontend:upload-images-to-icp-asset/src/outbound/upload_files.rs at main · Veercodeprog/upload-images-to-icp-asset · GitHub
backend:
GitHub - Veercodeprog/upload-images-to-icp-asset-backend-

The console shows to me (besides a bunch of websocket errors) https://unuoe-3aaaa-aaaai-q3nda-cai.icp0.iofile-Screenshot as a malformed link to the screenshot. If I fix it to https://unuoe-3aaaa-aaaai-q3nda-cai.icp0.io/file-Screenshot I get the error

Replica Error: reject code CanisterError, message IC0503: Error from Canister unuoe-3aaaa-aaaai-q3nda-cai: Canister called `ic0.trap` with message: Panicked at 'Cannot use Func directly. Use `define_function!` macro instead.', /Users/veerpratap/.cargo/registry/src/index.crates.io-6f17d22bba15001f/candid-0.10.10/src/types/reference.rs:83:9.
Consider gracefully handling failures from this canister or altering the canister to handle exceptions. See documentation: http://internetcomputer.org/docs/current/references/execution-errors#trapped-explicitly, error code Some("IC0503")

Looks like you’re not properly registering some of the canister interface.

If I use your candid UI link I get to https://unuoe-3aaaa-aaaai-q3nda-cai.icp0.io/file-image-11.jpg, which shows that certification fails. How do you certify the uploaded assets?

i have made update to backend code as earlier i havent added teh logic for certification,
but still i ave some error on trying to access the file like :Response verification failed: Tree not found
for example i have uploaded the file and link generated is this:
https://unuoe-3aaaa-aaaai-q3nda-cai.icp0.io/file-image-12.jpg

updated logic of certification: upload-images-to-icp-asset-backend-/src/asset_proxy/src/state.rs at main · Veercodeprog/upload-images-to-icp-asset-backend- · GitHub

Your certificate does not contain everything it needs. AFAIU you only serialize the cert, nothing else. Here’s how the asset canister does it. You can read more about certification here

1 Like

i am getting this now
https://unuoe-3aaaa-aaaai-q3nda-cai.icp0.io/file-image-81.jpg
Invalid response body:
i have checked the type of the response:

which is quite same as the type in this :star2: sdk/src/canisters/frontend/ic-certified-assets/src/asset_certification/types/http.rs at 3405dc693391c144c97ab77d8a67cf70a3606343 · dfinity/sdk · GitHub

Invalid response body does not refer to the HttpResponse struct types. @NathanosDev, could this error message be improved?

The error gets returned if this function returns false. So it means that your response’s hash did not appear in the certificate tree in the expected place

1 Like

i have not implemented the response verififcation logic
, is it necessary

if you want to go through icp0.io then yes. If you are willing to go the less secure route and use raw.icp0.io instead, then you can skip it.

but even when i use raw link for images i get:
https://unuoe-3aaaa-aaaai-q3nda-cai.raw.icp0.io/file-image-79.jpg

but in the backend code i can directly enter the file-image-79.jpg in the retrieve method to get the image vector in bytes:
https://a4gq6-oaaaa-aaaab-qaa4q-cai.raw.icp0.io/?id=unuoe-3aaaa-aaaai-q3nda-cai

When you got to that link, the browser requests /file-image-79.jpg, not file-image-79.jpg. If you try the version with / in Candid UI you get the same failure

how can i correctly get teh image

is this what
i am looking for :response-verification/examples/http-certification/custom-assets at main · dfinity/response-verification · GitHub
doe sit have complete certification and validation example logic or do i need more things implemented?

https://unuoe-3aaaa-aaaai-q3nda-cai.raw.icp0.iofile-image-79.jpg/
this does not work at all

is it possible to get the vector of bytesusing retrieve method and then display it as the image

i am not sure about the validation logic implemented in here,
also not sure if validation is necessary

It’s on my list to improve those error messages across the board, I’ll make sure to include this one, thanks!

Yes, this is a complete example for certifying assets. This example is much simpler and does the same thing, but it uses an unreleased library. If you can wait some days then that library will be released very soon.

Although you can also just go ahead and use the library by linking with Git.

this?
cant wait though , can you point what should i improve in my code though?

could you brief this process?