How to upload a file to the network


#21

@hunterlester . Thank you for the api playground. It really helps to understand how it works. I am new to the entire concept of Safenetwork hence bear with me if my questions are naive. When I am following the steps I get error at Step 7 when I am trying to upload using the API playground “Account not found for ClientManager(name: f06168…)” at the power shell and “fileHandle: Core error: Routing client error -> Account does not exist for client” on API playground.
I am using windows 10 and I have cloned and compiled the dev-browser and safe_dom_api_playground yesterday. Any pointers would be really helpful.


#22

Welcome to the community and ask away!

Is this occurring after committing the file with window.safeNfs.insert?


#23

Thank you for the welcome and quick response. I was using the playground so used the option safenfs - create. Chose the file and clicked run. At this point I got the message.


#24

In Step 7, When I use safe web API playground, the file explorer selects the file, but does not return the fileHandle.
on inspecting console logs on Safe Browser (safe_browser-v0.2.1-linux-x64-mock on Ubuntu 16.04.2 LTS), getting error.


When I have the fileContent with static html data, it works.
Is it related to the tag type ? I used 15002.
Could someone point me in right direction.
I am trying to upload an image.


#25

@Saket @sadeesh.r Since created the original post, some things have changed in how mock routing works in addition to some other updates we are rolling out.

We are working on testing right now and will release updates soon to get you two back on track.


#26

@hunterlester Thanks for the reply, we will wait for the updates.


#27

Check out my website safedemo.jam it uses a function called blobtobuffer which will get rid of your error, I’ve released a video that goes through the code this is from .

   function blobtobuffer() {
  var reader = new FileReader();
  reader.readAsArrayBuffer(file.files[0]);
  reader.onload = function(event) {
    content = new Buffer(event.target.result.byteLength);
    var view = new Uint8Array(event.target.result);
    for (var i = 0; i < content.length; ++i) {
      content[i] = view[i];
    }
    return content;
  };
}

#28

Thanks, I will look into it.
I have tried FileReader Api and able to get the data uploaded in binary string format, but unable to upload file data from buffer array.


#29

I had the same problem but this code fixed it
I think it works because the safe DOM api expects a node js like buffer which is a bit different to the usual JavaScript buffer, the code I used gives back a buffer node js can interpret


#30

thanks @Joseph_Meagher, i loaded the content from array buffer as you mentioned in blobtobuffer function, it works perfectly :+1:


#31

It fails at step 4 of building the dev browser for me.

After I run “npm run pack-authenticator” I get an error message.

Copy-Item : Cannot find path ‘G:\safe_browser_dev\safe_browser\app\node_modules\beaker-plugin-safe-authenticator\src\ffi\system_uri.dll’ because it does not exist.

I don’t have a “beaker-plugin-safe-authenticator\src” folder, but I do have a folder called “beaker-plugin-safe-authenticator\dist” that does contain the system_uri.dll file though.


#32

I’m going to update the links in the original post. We have updates being released today that will clean up this mess :smiley:


#33

Links updated. We are not using my dev-mode monstrosity anymore.

A big thank you to @Joseph_Meagher for informing me about native FileReader


#34

Thanks @Joseph_Meagher @Hunterlester :+1:t4: for your help to enable us to progress on this.


#35

Could someone explain what the rationale is behind the _public container?


SAFE Containers and NFS emulation - summary
#36

I’ve checked the safe_app Web API and the function below in step 5 is not found.

window.safeMutableData.newPermissionSet(appHandle)
.then((res) => {
permSetHandle = res;
return 'Returns newly created PermissionsSet handle: ’ + res;
});

It is needed in the following steps. Is there something needed to change in order to continue?