IPFS add files ISSUE - ipfs

I'm currently having issue with writing an script for uploading a file to IPFS. For some reason I'm always getting a TypeError, in which ipfs.files.add or ipfs.add is not a function. How could I resolve this?
My Code:

Related

Unable to update local json file in React native app

My React Native app file structure looks like this:
/assests
/json
example.json
/components
view.js
I need to take input from the user in the view.js component and store it in the example.json file for future use. I tried using react-native-fs but could not figure out how to use it to get the absolute path of example.json and the relative path kept on throwing errors. If there is some other way to do this, it would be most appreciated.
Thanks in advance for the help!!!!
Found out what the problem was. I was trying to update files that are in the app bundle and forgot that they are read-only. So I copied the files from the app bundle to the document directory and is accessible from there. I can edit and delete from there.

Can't Find JS file in Console

I am pretty new and I am trying to work with the GIPHY API, but I can not get my js file to be found in the browser. I have tried to create a whole new repo and I got the same issue. Can anyone help?
Here is my directory:
Image with error
Here is my HTML. Can anyone Help?
Folder structure
When I look in the console I get the message:Failed to load resource: net::ERR_FILE_NOT_FOUND
There is teh GIPHY sample code in the file so it is not empty.
Your path is not correct you need to point to the exact location your file is.
Try with ../js/main.js instead of js\main.js
For the standard way, you should move your index.html file in the root of the project and then point your js file like this js/main.js instead of js\main.js
If you can make your source to be just the file name likemain.jsalone
It will make you avoid the mistake of js\main.js thus solving the issue

File not found when run project from browser

I write a function to read data from excel file, then generate whole datas to JSON. When i test running as application, it works well. But when i call that function into Servlet class and using browser to run it, the file not found exception come. I put the excel file to root folder of my project and URI is the same. Is there any one have ever had same issue with me? and know how to fix it? Thank.

SevenZipArchiveException: Invalid archive. open/read error

I got the following error when I try to extract a zip file:
"SevenZip.SevenZipArchiveException: Invalid archive: open/read error! Is it encrypted and a wrong password was provided?
If your archive is an exotic one, it is possible that SevenZipSharp has no signature for its format and thus decided it is TAR by mistake."
Nothing works with zip files, but everything works fine with 7z files. Is it possible to extract zip files with the SevenZipExtractor?
string sourcePath = #"c:/temp/yyy.zip";
using (var file = new SevenZipExtractor(sourcePath))
{
file.ExtractArchive(outputPath);
}
What I found with this error when I encountered it was that it was an issue when I would attempt to decompress a certain set of files. For example, if you were to run the SevenZipCompressor and say it stopped halfway through, this would corrupt the compression of said files, so when you would attempt to decompress the files, the error would occur.
The fix for me was to recompress the set of files and to be sure it ran completely, and then the error went away, allowing the extraction to work.
So the moral of the issue at hand is to look at the source in this case and make sure the files or the archive aren't corrupt.
I've run into the same issue recently with version 18.5.0.
Downgrading the package to 9.38.3 solved the problem for me.
For people still running into this problem: this can also happen when trying to uncompress rar5 files that have filename encrypted turned on.

How to load a local directory in as3

I want to load a directory in actionscript. To do that I use the File class but sadly it doesn't work.
Here is what I did. First I created the directory in the applicationStorageDirectory using this code:
var root:File = File.applicationStorageDirectory.resolvePath(UIDUtil.createUID());
root.createDirectory();
After that I dispatch an event so that the application copies some files into that folder. To do that I use the method File.copyToAsync (that works, so this is not the problem). When all files are copied to that directory I try to load that directory using the File call again. The reason I want to do that is, that I need the content/data as a byte array. The data property of the File class is only set when the load method is called successfully before.
Since the directory is in the application storage directory (the url property of the file object has this content: app-storage:/FF011DBC-2E92-46A8-D5F8-29FE1DD8FA7A) I thought just calling the load method would work. I was wrong... Although the documentation of that method says I can just call that method when the application runs in AIR and the file to load is inside the application sandbox, I get the following error:
Error #2044: Unhandled IOErrorEvent:. text=Error #2038: File I/O Error.
at flash.filesystem::File/resolveComponents()
at flash.filesystem::File/resolvePath()
...
Do you have any ideas what could be wrong? Is it even possible to load a directory using the File class? Or does that error occur because the isDirectory flag is set to true in the file object?
kind regards
Markus
I believe a File, when pointing to a directory, does not contains the data of the files contained inside it. You would have to use File.getDirectoryListing() to loop over all files the folder, and append their bytes to the ZIP archive separately. Don't forget to check if you come across sub-directory...
You can check this link for an example of how to do this.