i am trying to unzip a zip file and save into target path
i tried these thing
var zip = new AdmZip(x);
zip.extractAllTo(/target path,false);
and then
fs.createReadStream(path/to/arch.zip).pipe(unzip.Extract({ path: "targetpath"}));
it is extracting the zip file and save that unzip file into target path.it is fine.
but if i upload the two zip file(it contain same name),it is overwrite that folder.
for example
first if i upload image.zip ,it will be extracted and it will be stored into images(target folder)
now images folder contain image folder.
again if i upload image.zip,it will be extracted and it will be overwrite image folder
so images folder contain again one image folder.
but if i upload image1.zip file , the images folder contain image and image1 folder.
so how to save even the folder contain the same name.
Related
Might just be an edge case but I extracted a zip file to a directory using the zip file module. When extracting, zip file names the directory it extracts to.
If there is a way I get to specify the name of the folder Zip file creates to extract the files to? I am hitting an error because I am using the same folder zipped up to test zip file and it keeps using the old folder name which already exists so it throws an error. Here is my code:
orginalFolderName = jobFolder + name
with zipfile.ZipFile(directory,"r") as zip_ref:
zip_ref.extractall(jobFolder)
os.rename(orginalFolderName, newFoldername)
directory = newFoldername
with zipfile.ZipFile(filepath) as z:
z.extractall(dest_folder)
filepath - Complete path of zipfile
dest_folder - destination folder
How to store multiple files with same name and extension using fs.
fs.createWriteStream(`${dir}${file.filename}`)
What I want is:
upload image.jpg -> uploaded image.jpg
upload image.jpg -> uploaded image-2.jpg
upload image.jpg -> uploaded image-3.jpg
Currently I can not upload new file with same name
I am trying to delete the folder with name "repro" and its contents in my build drop location. I have configured my delete files steps as below
Source Folder: $(BuildDropLocation)\$(BuildNumber)\CTrest\lime
Contents:
**/repro/*
repro folder resides here
$(BuildDropLocation)\$(BuildNumber)\CTrest\lime\version\package\code**repro**..
Is there something that I am missing here?
Here is the doc for the command: Delete Files task. Examples of contents:
**/temp/* deletes all files in any sub-folder named temp.
**/temp* deletes any file or folder with a name that begins with temp.
I think, **/repro* will be more suitable in your case.
I have this Nodejs lambda function where some files are in a subfolder, like this:
- index.js
- connectors/
- affil.js
I have a Cannot find module error when trying to require the affil.js file. Trying to read it with fs.readFile returns an access denied error.
When I move the file to the root folder, it is accessible. Is there a requirement that Lambda functions files must all be at the root directory? How can I fix that?
Mostly it is because of the way zipping the files making the problem. Instead of zipping the root folder you have to select all files and zip it like below,
Please upload all files and subfolders like below. Please include node_modules folder as well in the zip.
As pointed by #Vijayanath Viswanathan, the issue is with how the zip file is created rather than Lambda.
I used to feed gulp-zip with this:
var src = gulp.src('src/**/*')
The correct way is to prevent folders from being included:
var src = gulp.src('src/**/*.js')
or (if you need to include file with other file extensions)
var src = gulp.src('src/**/*', {nodir: true})
I need to download all files and folders from an s3 bucket to a local folder in sam hierarchy.
Suppose my s3 bucket basepath is: myBucket/user1/
in which and user1 may have dynamic values. Every folder for users contains 3 sub folders image, audio, video and files in them.
i just want to download all files in folder user1 to local file system in paths
/assets/s3files/user1/<FILES & FOLDERS HERE>
i have tried: skipper-better-s3, but it reads one the file we have passed.
adapter = require('skipper-better-s3')({
key: 'xxxxxxxxx',
secret: 'yyyyyyyyyyy',
bucket: 'myBucket'
});
adapter.read('/assets/s3files/user1/image/file1.jpg', (err, data) => {
// data is now a Buffer containing the avatar
});