Attach more file on request with express-fileupload - express

We are using express-fileupload to uploading file on express project. Currently with some special case we want to add more file into request with some url. We create a new middleware to attach new file into request.files but not success.

Related

How to validate that the path of an uploaded file is not malformed

I'm developing an application with next.js
I have an api endpoint that receives FormData in the request.
I'm using Formidable to get the files from the request.
Than, upload the file from its temporary path on the server to AWS S3.
My question is, how can i validate that the user didn't malformed the path of the file, and sending the request with a malicious path. For example, changing the path to "../../secretFile".
A regular path for example would be:
C:\Users\MyUsername\AppData\Local\Temp\upload_e69daadcd956ae15fc00551832d1be82

Dropbox HTTP API v2 overwrite files when moving them

I'm using the /files/move endpoint on Dropbox API v2, but getting the error that a file of the same name exists in the destination directory (which it does).
How can I set the HTTP request to simply override the existing file with the file being moved?
I just got confirmation from Dropbox that overwrite is not possible for the /files/move endpoint (at this time).
The API doesn't currently offer mode options like this (e.g., to force an overwrite) for the copy and move endpoints, so you'll need to delete the existing file first. We'll consider this a feature request though.

Yii 2.0: How To configuring file upload and access for backend and frontend in Yii2 advanced app

i have uploads file in yii2 advance app.
but, one problem found.
i have uploads file in "backend/web/uploads". but, not access in frontend.
so, how to uploads & access file in common directory.
You can easily access backend/web/uploads from the frontend, you just have to use the #backend path alias.

How to Upload PhantomJS Page Content to S3

I am using PhantomJS 1.9.7 to scrape a web page. I need to send the returned page content to S3. I am currently using the filesystem module included with PhantomJS to save to the local file system and using a php script to scan the directory and ship the files off to S3. I would like to completely bypass the local filesystem and send the files directly from PhantomJS to S3. I could not find a direct way to do this within PhantomJS.
I toyed with the idea of using the child_process module and pass in the content as an argument, like so:
var execFile = require("child_process").execFile;
var page = require('webpage').create();
var content = page.content;
execFile('php', '[path/to/script.php, content]', null, function(err,stdout,stdin){
console.log("execFileSTDOUT:", JSON.stringify(stdout));
console.log("execFileSTDERR:", JSON.stringify(stderr));
});
which would call a php script directly to accomplish the upload. This will require using an additional process to call a CLI command. I am not comfortable with having another asynchronous process running. What I am looking for is a way to send the content directly to S3 from the PhantomJS script similar to what the filesystem module does with the local filesystem.
Any ideas as to how to accomplish this would be appreciated. Thanks!
You could just create and open another page and point it to your S3 service. Amazon S3 has a REST API and a SOAP API and REST seems easier.
For SOAP you will have to manually build the request. The only problem might be the wrong content-type. Though it looks as if it was implemented, but I cannot find a reference in the documentation.
You could also create a form in the page context and send the file that way.

Handling file uploads with Restler

What is the best practice to implement file uploads using Restler framework?
I like to have a API call that get the file save it in CDN and return back the CDN file URL to the caller. What is the best way to implement it?
File upload to CDN using our API
This requires two steps, first is to get the file on the API server.
add UploadFormat to the supported formats
Adjust the static properties of UploadFormat to suit your need
From your api method use $_FILES and move_uploaded_file to get the file to the desired folder. This step is common for any php upload process.
Now that you have the file on the server
Upload it to CDN. You can use any means provided my your CDN. It can be ftp or using some SDK to do the upload
Construct the CDN url and return it to the client