Don't overwrite existing file nodejs express-fileupload - node.js

I tried out the express-fileupload sample project, to test uploading files. However, if I upload a file with a name that is already uploaded e.g. test.jpg (uploaded) test.jpg (to be uploaded) it just overwrites the old file. Is there an easy way to prevent this or do I have to code something that checks if that file already exists.
Sample Project: https://github.com/richardgirges/express-fileupload/tree/master/example

Related

Process files from postman or UI in Node JS, without storing them in local storage

I am using multer npm library to read files from postman and I am getting the file and its details in my node js code(checked via logging req.file), but my concern is I don't want the file to get stored in my local machine, I just want to extract the data from the file and process further for my requirements.
Is this possible or anyone can suggest me some solutions to this.
Thanks in advance
As I read multer libraries, it streams the uploaded file in the disk, and then it processes the file.
If you only want to use the properties like mime/type or originalfilename of the file you can use multer and in the storage options after getting the uploaded file properties, use cb(null, false) to prevent storing the file, but if you want to process the file, you can remove it from the disk after your process is done.

Can't create .zip file with Azure Logic Apps' SharePoint Create File action

I'm trying to create a .zip file by passing the returned body of an HTTP GET request to SharePoint's Create File.
Body is:
{
"$content-type": "application/zip",
"$content": "UEsDBBQACA...="
}
Shouldn't this just work? The docs only define the Create File field as "Content of the file." but that's not super informative...
I believe I've done this before with a file that was application/pdf and it worked. Unfortunately, I can't find that Logic App (I think it may have been an experiment I've since deleted).
I should note that the Create File action does create a valid .zip file, in that it's not corrupt, but archive is empty. It's supposed to contain a single .csv file.
I tried decoding the Base64 content and it's definitely binary data.
Any idea where I'm going wrong?
I test with Postman and when I use the form-data way to POST the request, I found the .zip file couldn't be open. Then I check the Logic App run history and I find the problem is if just use the triggerbody() as the file content it will fail.
This is because the triggerbody() not just have the $content, so I change the expression to triggerBody()['$multipart'][0]['body'] then it works and the .zip file is full.

Can Gitlab API upload file to repo?

https://docs.gitlab.com/ee/api/projects.html#upload-a-file
After upload image, I got the url, but didn't added to my repo files?
Can we upload image to repo files?
The /projects/:id/uploads doesn't add anything to your project's repository. The description says:
Uploads a file to the specified project to be used in an issue or merge request description, or a comment.
To upload a file to the actual repo you need to use the /projects/:id/repository/files/:file_path endpoint.
To upload an image specifically, you'll need to:
Set the encoding parameter to base64
Convert your image to base64
Remove the data:image/png;base64, part at the beginning
Set the content parameter to the remaining part of the base64

How to validate file to be uploaded?

I am working on liferay project. I have to put file upload functionality. For which I have used
<bridge:inputFile/>
But my upload method is not called when I try to upload a blank file of 0 bytes. Actually my validation for blank file is inside my upload method.

CodeIgniter - Directory Traversal - sanitize_filename()

If I use the CodeIgniter File Upload Class and rename the image being uploaded using:
$config['file_name']
do I still have to use
$this->security->sanitize_filename()
on the image being uploaded by user?
just set $config['encrypt_name']; will automatically rename users uploaded file or image for more information check user guide of File uploading library
File Upload Library

Resources