Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

redrezo11's avatar
redrezo11
New member | Level 2
6 years ago

How to handle temporary files that are created by uploading files?

Sort of new to web dev in general so forgive me if I don't know what to do. The issue is that in my local project repository. Temporary files are being created. I'm not sure if this is an issue to be concerned with? I worry what will happen after deployment and whether this will cause issues down the line. Are we suppose to just let the host clean the files automatically or are suppose to manually flush the temporary files created after file upload? I plan to deploy on Heroku for my web app.

 

Here is some code to let you know what is going on. I'm using the Dropbox SDK for Javascript.

Express -> using Formidable / Form as middleware to parse request.

app.post('/form', (req,res)=>{
		let success = null;
		//take the file and send it off to dropbox
		form.parse(req, (err, fields, files) => {
			console.log("fields:", fields);
			console.log("file:", files.myfile);
			console.log('filename:', files.myfile.name);
			// if (files.myfile.size > const UPLOAD_FILE_SIZE_LIMIT) 
			if (files.myfile.size<UPLOAD_FILE_SIZE_LIMIT) {
				dbx.filesUpload({path: "/ReflectionsBucket/" + files.myfile.name, contents: files.myfile, autorename: true})
				.then(res=>console.log(res))
				.catch(err=>console.log(err));
				success=true;
			} else {
				success=false;
			}
				
		}); //form.parse

		//need to add the event when the form ends using form.on('end')

		form.on('end', ()=>{
			if (success)  res.send('post successful');
			else res.send('file size is too big, needs to be under 150mb');
		});

		

	});

 

1 Reply

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!