How to handle Optional Blob

Here

type UserRequest = {
user : Principal;
profile : ?Blob;
};

How i can pass the above type this in console to a method that takes NewUser as the parameters

public shared(msg) func createUser(userRequest : UserRequest) : async userID {
};

Hoow i can call the above method in the console ?
dfx canister call dfibook createUser

Thank you

Hi,

Here is an example of an implementation with two ways of doing it on the command line:

Motoko:

public func addOrUpdateChunk(id : Id, chunk : Blob, crcSum : ?Nat32) : async Result<Nat32,Nat32> {
        itemsStore.put(id,chunk);
        let sum = crc.checksum(Option.get(itemsStore.get(id),Blob.fromArray([0x0])));
        switch crcSum {
            case null #ok(sum);
            case (?value) {
                if (Nat32.equal(sum,value)) {
                    #ok(sum)
                } else {
                    #err(sum);
                };
            };
        };
    };

Shell bash

dfx canister call qispi_msg_store addOrUpdateChunk '(record {"id01-test";3},(blob "123456789"),null)' | grep ok
status=$((status + $?))
dfx canister call qispi_msg_store addOrUpdateChunk '(record {"id02-test";1},vec {0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 26; 255},null)' | grep ok
4 Likes