cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

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

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

redrezo11
New member | Level 2

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.

Dropbox file upload.png

 

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 1

Greg-DB
Dropbox Staff

I'm afraid we can't be of much help with this unfortunately, as it doesn't seem these files are being produced by Dropbox code.

 

The Dropbox JavaScript SDK is open source, so you can see what it's doing at the following locations in the code for the 'filesUpload' method you're using, for instance:

The method just uploads whatever content you supply to that 'contents' parameter.

 

Perhaps the files are produced by your web framework itself, for the files posted in that form to begin with? In that case, I'd recommend referring to the documentation/support for that framework.

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?