Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I stop file extension being remembered and applied on download from Google Drive

I uploaded a mixed load of files (images, docs, pdf) all of which had the file extension of .dc Files were converted or not according to the underlying type. As part of the migration process I used Google apps script to rename these files and applied appropriate files extensions like .pdf. Selecting any of those files and downloading results in a file with an extension like .pdf.dc

Where is the .dc coming from and can I get rid of it in my GAS renaming process?

like image 852
DavidF Avatar asked Oct 07 '22 07:10

DavidF


1 Answers

You are right, there seems to be no good way to change the original extension directly. I believe this is because the original extension must have something to do with the MIME type information and its hard to shake that off.

However, if you make a copy instead of renaming, the new name drops the old extension.

Here is what worked for me (just tested with gifs and jpgs, can't just convert a JPG to GIF like this...) -

var file = DocsList.getFileById('MYID');//name is 'test.jpg'
file.rename('test.gif');//name is now 'test.gif.jpg', not desired
file.makeCopy('test.gif');//new file is created with download name of 'test.gif'

I understand this isn't ideal as you have to make copies and delete the original, but this could be a decent workaround for now.

Please log an issue in the issue tracker with details of your use case so that we can dig into this further.

like image 80
Arun Nagarajan Avatar answered Oct 10 '22 02:10

Arun Nagarajan