Create Lambda function using Python API (Boto3) by using zip file - amazon-web-services

I have a zip file ready for the lambda function, but in the doc, the zip file is required to be read as binary (so it seems). I can open the zip file and read the files inside as binary, but how do I read the zip file as a binary?
The doc: https://boto3.readthedocs.io/en/latest/reference/services/lambda.html#Lambda.Client.create_function

nevermind, a simple open(file_name, 'rb').read() does it for me. Forgot the 'b'.....

Related

How to detect new file download in Windows OS?

I am making a program that scans any new file downloaded into the system.
Currently, I have used a file watcher that monitors a directory.
Whenever a file is downloaded from chrome then the following happens :
For example: Let's say a pdf file is being downloaded.
.tmp file created first
.tmp file is renamed to .crdownload
.crdownload is modified multiple times
.crdownload file is renamed to .pdf
.pdf file is modified multiple times.
The problem is when can I say a file is downloaded because it is modified multiple times after renaming from .crdownload to .pdf file.
Is there any way to detect a new file downloaded into a system?
Thanks for the help.
Platform: Windows
Language: C, C++
from what I understood you want it to get the file final extension,
for this you can check the file extension evrytime to see if it is a .tmp or
.crdownload; but not check for if it is a new file.
Sorry for my bad English,
Hope this helps.

Amazon S3 Compressing Files?

A few years ago I uploaded some photos to S3. When I try to retrieve them today, the files seem to be corrupted, as I am unable to open them in the browser or with a photo editor. Looking at the file properties, it seems the files have been compressed, as there is a x-amz-meta-compression-algorithm key with the value zlib and a x-amz-meta-compression-original-size with a value of 53890. However, the size of the file on S3 is 53761. I did not compress the files before uploading them. How can I uncompress these files?
Did you download the file and determine its type using file command?
If it is indeed zlib compressed or if file command says data, try the accepted answer in this link: https://unix.stackexchange.com/questions/22834/how-to-uncompress-zlib-data-in-unix
printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" |cat - zlib.raw |gzip -dc > myfile

How to get the extension of a file in windows

Is there any way so that i can get extension of a given file.
if suppose there is a file "abc.txt" but after renaming the file name is "abc.exe" now the extension is .exe is there any way that i can get the original extension of a file in which it was created.
I looked for GetFileInformationByHandle but that was not much of help
is there any way that i can get the original extension of a file in which it was created
No, not without any operating system add-ons or a simple backup of the file
.

Zlib and Minizip - How to add a new directory to a .zip file

I have written an application to compress the contents of directory to a .zip file from C++, using zlib and minizip. Minizip is not well documented online but the file "zip.h" in the source code contains comments.
My application uses FindFirstFile and FindNextFile to get a list of all files (and subfolders) in the directory and then, as shown here How do I use Minizip (on Zlib)? creates a .zip file and opens new files within the .zip.
Then I read the source files with fopen and fread and write the contents to the newly created files in the .zip folder. This all works just fine if the directory to be compressed contains only files, and no subfolders, but I cannot decipher from the comments in the source code how I add a new folder to a .zip file and then write files to that folder.
As it turns out, you don't need to create a new directory in the .zip file as a separate step. You can just pass the parameter "foldername\filename.ext" to the zipOpenNewFileInZip method and it will create the "foldername" directory for you then add a new file "filename.ext" to that directory.

Open a zip file and move the file in another zip in c++?

I wanted to open a zip file (mod.zip) and move the file inside, to another zip file (minecraft.zip) and owerwrite the file with same names.I hope you understand because im not english.
I dont know if i can open zip files or i need libraries
I would recommend 7zip SDK, it lets you zip and unzip things in .7z and .zip and many other formats