How am I able to access my file with IPFS, with no peers? - distributed

I'm new to ipfs, so I've been running some tests. What I did is, I created a simple text file and added to ipfs, I deleted my local file and I used ipfs cat and was able to read the contents of the file. But my confusion comes when I run ipfs dht findprovs <hash> and the only ID I get is my ID, but since I deleted the file from my computer, where exactly is it being stored? Why am I not getting another peer ID?

It is in the repository of your local IPFS node. You can browse it by right clicking the IPFS status icon > click Advanced > click Open Repository Directory.
If the file is not pinned, it stays in the repository until the garbage collector does its job. If it is pinned, it will stay there forever.
You're not getting other peer IDs probably because no other peer has accessed your file.

Related

How can I call ReactJS chunk files via sharepoint master page without webpack configuration

I developed an application with ReactJS and got chunk files with npm run build. But how can I call these files via sharepoint master page. I just add the main chunk files to master page and loaded it but it never called the component and it doesn't render.
I uploaded the below files to the SiteAssets folder in SharePoint. I just the call main.553276c9.chunk.js via master page.
0.45984e43.chunk.js
0.45984e43.chunk.js.LICENSE.txt
0.45984e43.chunk.js.map
3.e5ccfe13.chunk.js
3.e5ccfe13.chunk.js.LICENSE.txt
3.e5ccfe13.chunk.js.map
4.bdcd656e.chunk.js
4.bdcd656e.chunk.js.map
5.41ddc0b8.chunk.js
5.41ddc0b8.chunk.js.map
6.cc7d4939.chunk.js
6.cc7d4939.chunk.js.map
main.553276c9.chunk.js
main.553276c9.chunk.js.map
runtime-main.85cbbfa2.js
runtime-main.85cbbfa2.js.map
Most build systems that generate files like this should also generate an index.html file that should load and run your app. You should upload that html file, along with all js files, and run your app from that.
If you're using Create React App with react-scripts the index.html should be in build/index.html.
According the documentation runtime-main.85cbbfa2.js is file to include.
runtime-main.[hash].js
This is a small chunk of webpack runtime logic which is used to load and run your application. The contents of this will be embedded in your build/index.html file by default to save an additional network request. You can opt out of this by specifying INLINE_RUNTIME_CHUNK=false as documented in our advanced configuration, which will load this chunk instead of embedding it in your index.html.
Just note that that filename will change when the code changes. The build process will update your HTML file, with that new filename. So you definately want to be in the habit of uploading that.

React not fetching data from the updated env file

There are some environment variables in my .env file that gets updated when some values get updated on the database.
Example:
REACT_APP_FIREBASE_ID=1234567890
When I log this to the console on my react app:
console.log(process.env.REACT_APP_FIREBASE_ID) //this gives "1234567890"
But when the .env file is updated with something else:
Example:
REACT_APP_FIREBASE_ID=9876543210
The log still gives the old value:
console.log(process.env.REACT_APP_FIREBASE_ID) //this still gives "1234567890"
I am using on CRA on dev mode with "npm start"
If I terminate the server and restart it again, I am able to see the correct output to the console.
BUT, this doesn't work after "npm run build"
How can I clear the environment cache after the .env file is changed on the Production Mode?
This is how I solved it.
My first approach was to get the value from the .env file, but unless the server is restarted, this approach doesn't work. [BAD]
My second thought was to create a JSON file and keep the data from inside that, and update the JSON file whenever the Database is updated.
Sadly, this was a very bad approach because CRA (or probably any react project) cannot call a file outside the src folder and after the build, there is no scope to change the built js files. [VERY BAD]
Finally, I managed to solve this using this approach [DECENT, I Guess]
Saving the data on a table in a key-value format (You may just save in JSON format too)
When the application is loaded (main component is loaded), call an API that gets that key-value(or JSON) and store the data in the LocalStorage of the browser.
Get the value on the application with localStorage.getItem("theKeyName")
A Tip:
You could check if the key is already present on the LocalStorage before making the API call.
if(localStorage.getItem("theKeyName") !== null) {
//your API fetch request or redux dispatch
}

Custom domain using create-react-app for github pages

I'm not sure what I'm doing wrong. i've followed all the steps to set up a custom domain name, but maybe I'm missing something.
I followed the steps in this article so my settings look like this:
A Record # 192.30.252.153 Automatic
A Record # 192.30.252.154 Automatic
CNAME Record www myusername.github.io. Automatic
I added a CNAME file which only has my domain name in it.
I added the CNAME file to the public folder of my react app as the instructions here state.
I went to my github settings and set the domain name. It currently has a checkmark saying that my site has been published.
Going to my site here gives a 404 error. What else am I supposed to do?
I had a similar issue when trying to set a custom domain with create-react-app on a github project page.
An easy solution worked for me is:
Add a "CNAME" file in the "public" folder with only the domain in this file(start with "www" without "https://");
Change the homepage in the "package.json" file from "https://xxx.github.io/xxx" to your domain that you put in the "CNAME" file with "https://";
In Git Bash, follow the basic steps 'git add .', 'git commit -m "change"', 'git push origin master' to update the changes;
In Git Bash still, run "npm run deploy", then type the domain in your browser (clear previous history), it should show up the lovely "welcome to React" page.
Regards,
It is definitely not giving a 404. It seems some of the links to your loaded js/css files are malformed, but the index.html is loading just fine.
You should keep in mind that your ISP and your computer both try to cache information about where a given domain name should route to. This can sometimes mean that the path to the destination IP is cached and will show you the out of date resource immediately after a new CNAME is added.
Most ISPs guarantee a refresh of the related cache within 48 hours. If you need to check faster than that, I would try to find a different internet connection and device to use to access the page after you have everything set up. Smart Phones are invaluable for this, just make sure the wifi is turned off.

move_uploaded_file in php not working on heroku

I am uploading images using move_uploaded_file function in php code, but it does not saving the images in a images folder of my app on heroku.
following is the code:
if(move_uploaded_file($bannerfile['tmp_name'],$bannerfilepath)){
...
}
filename and path are correct but images are not saving.
First thing you should do is to check your folder permission, assign a proper permission to the folder which you want the image to be uploaded, (read + write permission).
If it fails, tries to debug your data and make sure the data is correct.
And also, what is the max file size and post_max_size in your php.ini? If the file is bigger, then PHP will stop this and the data will be empty.

Retrieve file relative to play application path

I created a Play! app and deployed it under TomCat. This works well. The only problem is the management of a properties file, currently in the conf folder right next to application.conf. But as soons as the client replaces the war file the custom properties are overwritten with the default values, resulting in errors.
Now I want to introduce a seperate properties file placed inside the webapps folder. This way I will be sure my clients will not overwrite the file 'accidentally'.
So the structure would be:
TomCat webapps:
myPlayApp
PlayConfig <-- here I want to place the config file
So I would like to retrieve the properties file by something like:
getFile("../PlayConfig/app.properties");
This obvious does not work, but I do not know how to achieve this?
I thought retrieving it by tomcat http url but the portnumber my vary, so this would also not work, I guess...
UPDATE 2012-01-25:
Actually when using the following code:
Play.applicationPath.getPath();
I get the absolute path when running the project outside tomcat (so not inside war file!)
When I deploy the same project in a TomCat server I get the following output:
W:\tomcat-5.5\webapps\MyTestProject\WEB-INF\application.
From this point on I can indeed use a relative path.
I think that when deployed in a Servlet container, play uses the /WEB-INF/application as base directory.
Try changing the path relative to this folder.

Resources