I have a file myarchive.zip that contains many directories, files, etc. Let's say this myarchive.zip file lives in a directory called "b". Currently, I am using the unzip module in Nodejs, using that I am able to create a directory by default called "myarchive" with the contents of the zip file. I do not want the code to create this "myarchive" directory - I just want the contents to be extracted to directory "b". Is this possible? If so, then how. Thanks!
The function that I am currently using for unzipping is:
const extractArchive = async (inputFileName, extractToDirectory) => {
fs.createReadStream(inputFileName)
.pipe(unzip.Extract({
path: extractToDirectory
}));
PS: inputFileName is the path of the zip file(base directory in which zip is present+ the file name)
Related
I'm trying to unzip a file that includes files and folders , but i can only see
one file got extracted and rest of the files and folders are missing after unzipping it. I'm using unzipper library.
Here is the code snippet:
var writeStream = fstream.Writer(outputPath);
readStream
.pipe(unzipper.Parse())
.pipe(writeStream)
Update
After looking at closely, it looks like only last file from zip exists in the target directory.
Did you tried this
const unzipper =require('unzipper');
const fs =require('fs');
fs.createReadStream('./files.zip')
.pipe(unzipper.Extract({path:'output/path'}))
reference
I am trying to create a file uploader which will store file in stored_images directory as shown below:
/project
/bin
/stored_images
/routes
/public
After the file has been saved here, I want to send url of the saved file to my front-end javascript. How can I get the url of file in stored in stored_images directory?? Or is there other better way to do this??
First tell express where to look for static files.
app.use(express.static('public'))
Then put you images folder in your public folder. Then the url to your images would be the path from within the public folder to your images.
For example /my_images/cool_pic.
I am using gulp-zip to zip up my source files. So I have a main folder called FIFA which has other sub folders which might have more sub folders and files. In additon the FIFA folder also has files like my package.json, gulp.js and some other files. I want to basically use gulp-zip to zip up my entire project and create a folder called distribution and save the zip inside it. So this is the code i used.
gulp.task('zip', function () {
return gulp.src('./*,')
.pipe(zip('test.zip'))
.pipe(gulp.dest('./distribution'));
});
The issue is that although a zip is created inside the distribution folder that zip only contains the files inside the FIFA folder, all the files inside the subfolders of FIFA are not there. So for instance if FIFA has a subfolder called ronaldo and ronaldo contains goal.js that goal.js is not in the zip. What have i done wrong? Please advice.
Try it with two *
gulp.task('zip', function () {
return gulp.src('./**')
.pipe(zip('test.zip'))
.pipe(gulp.dest('./distribution'));
});
What's the difference between * and **?
One star means all files, no folders - too stars will be more deep and also include all the folders inside the specified folder.
And for instance if you wanted to do two stars to include all folders EXCEPT one specific folder , is that possible to do also?
You can use an exclamation mark like !./excludedDir, pass src as an array with the !... as one of the values
Hi i wanted to upload folder and move to some destination is it possible doing in php ? or at least i can read the folder name and create same folder in divination and copy all files into created folder.
You can do this with the new HTML5 directory capabilities. Just put the directory attributes in your input field. After you got the directory server-side, you can do everything you want with it.
URL for a simple guide:
http://www.w3bees.com/2013/03/directory-upload-using-html-5-and-php.html
Hy
I have a question, is it possible to unzip a file via php but by file to file? I read some some zip Exempels in the php Manuals but i need a Way to extracz one file and than the other file.
For example:
I have a zip file with many Folders and in this Folder are some pictures. Now i want to extracz the First zip item and check:
If it is a Folder
If true than create a new file, extracz the Folder, create a new Folder in this Folder and save there the new file
If it is a file, than check size and Type
If this is correct than do something with this file
Next item
I als wantask if it is possible to check via javascript the zip file?
I readed something about a zip Library
I only want to read all files and check size and Type before uploaded