How to block a file extension that is remembered and applied when downloading from Google Drive

I uploaded mixed file uploads (images, docs, pdf), all of which had a .dc file extension. Files have been converted or not according to the base type. As part of the migration process, I used Google script applications to rename these files and apply the appropriate file extensions, such as .pdf. Selecting any of these files and loading the results into a file with the extension, for example .pdf.dc

Where is .dc located and can I get rid of it in my GAS rename process?

+4
source share
1 answer

You're right, there seems to be no good way to directly change the original extension. I believe this is due to the fact that the original extension should have something to do with the MIME type information and it’s hard to reverse it.

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

Here is what worked for me (just tested with gifs and jpgs, can't just convert 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 that this is not ideal, since you need to make copies and delete the originals, but at the moment this may be a good solution.

Please report the problem in problem tracking with details of your use case so that we can delve into that.

+4
source

Source: https://habr.com/ru/post/1439947/


All Articles