![PyPI Now Supports iOS and Android Wheels for Mobile Python Development](https://cdn.sanity.io/images/cgdhsj6q/production/96416c872705517a6a65ad9646ce3e7caef623a0-1024x1024.webp?w=400&fit=max&auto=format)
Security News
PyPI Now Supports iOS and Android Wheels for Mobile Python Development
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
google-drive-wrapper
Advanced tools
Wrapper to simplify transferring files to/from google drive.
The npm google-auth-wrapper (npm/ github) can be used to get the credentials required to access your google drive account.
By default it both compresses and encrypts files as they are transferred to google drive. If compressed/encrypted they are decrypted/decompressed as they are download from google drive. Before using please ensure you have validated that the encryption is suitable for the data you are protecting and that you have verified the implementation.
This modules provides these methods:
They allow individual files to be uploaded/download and the contents of directories to be uploaded and downloaded. On upload they allow a file to be converted into a google doc format for sharing/editing in the same manner as any other googlo doc.
As examples, the following use the uploadNewFiles, downloadNewFiles and uploadFile methods (of course use your own passwords, not the ones shown!). See the info for google-auth-wrapper for how to create the required 'client_secret.json' and 'client_secret.token' files:
This example downloads all files in the google drive file 'backups' into the local directory 'download':
var googleAuth = require('google-auth-wrapper'); var gdriveWrapper = require('google-drive-wrapper'); googleAuth.execute('./', 'client_secret', function(auth, google) { var wrapper = new gdriveWrapper(auth, google, 'goodpassword'); wrapper.downloadNewFiles('backups', './download', function(err) { if(err) { console.log(err); } }); });
This example uploads all files from the local directory 'upload' to the google drive directory 'backups'. Once transferred files are moved from the 'upload' directory to the 'upload-done' directory.
var googleAuth = require('google-auth-wrapper'); var gdriveWrapper = require('google-drive-wrapper'); googleAuth.execute('./', 'client_secret', function(auth, google) { var wrapper = new gdriveWrapper(auth, google, 'goodpassword'); wrapper.uploadNewFiles('backups', 'upload', 'upload-done', function(err) { if(err) { console.log(err); } }); });
This example uploads a text file and specifies that it should be converted into a google doc document that can be edited online like any other google doc:
var googleAuth = require('google-auth-wrapper'); var gdriveWrapper = require('google-drive-wrapper'); googleAuth.execute('./', 'client_secret', function(auth, google) { var wrapper = new gdriveWrapper(auth, google, 'goodpassword'); wrapper.getMetaForFilename('/backups/docker-images', function(err, parentMeta) { if (err !== null) { console.log('Invalid directory path'); } wrapper.uploadFile('testdoc', 'testdoc.txt', {parent: parentMeta.id, compress: false, encrypt: false, convert: true, mimeType: 'application/vnd.google-apps.document'}, function(err, meta) { if (err !== null) { console.log('Failed to upload file'); } else { console.log('Sharable link: https://drive.google.com/open?id=' + meta.id); } }); }); });
We need to disable both compression and encryption as we want the file to be plaintext so it can be converted. We then need to specify 'convert: true' so that the file will be converted on upload, and then we need to specify the mimeType for the type we want it to be convered to. In the case of the example we use 'application/vnd.google-apps.document' to ask that it be converted to a google gdoc document.
gdriveWrapper is used to create a new wrapper instance that can be used to invoke the other methods. It takes the following parameters:
uploadFile takes the following arguments:
The options object can optionally have the following fields:
downloadFile takes the following arguments:
If the name of the file with the specified google Id ends with the '.enc' file extension downloadFile will attempt to decrypt during the download. Similarly if the file ends with '.gz.enc' or '.gz' then downloadFile will attempt decompress the file during the download. (Its still a TODO to make this optional). If decrypted and/or decompressed the '.enc' and/or '.gz' extensions will be removed.
Downloads all of the files from the specific google drive folder to a local directory. downloadNewFiles uses a file called '.existing' in the local download directory to track files by their google file id. Once downloaded succesfully the file will not be downloaded again unless you specify a different local download directory or deleete the '.existing' file in the local download directory.
The download files will be named both by their file name in from the file metadata as well as the google file id. This is required because multiple files in the same folder can have the same file name in the meta data. The local files are named as:
fileid-filename
each file will be decrypted and or decompressed based on its file name as described for downloadFile() above.
downloadNewFiles takes the following arguments:
Uploads all files from a local directory in to a folder in google drive.
As files are uploaded each file will be encrypted and or compressed as described for uploadFile() above. (still a TODO to make this optional for uploadNewFiles()).
uploadNewFiles takes the following arguments:
Converts a path like name to a google file id. Finds the google file id for each segment and then limits search in next segement to the the file id for the previous segment. It will find the fist occurance of a file whoes filename matches a segment. Since multiple files with the same parent can have the same filename in their metadata this may not always get the file you expect. It is up to you to make sure you manage the naming of the parents so that the name you pass in will resolve to the expected google file id. For example if you resolve:
/level1/level2
you will need to make sure that only one file has the filename 'level1' at the root of your drive and that only one child of 'level1' is named 'level2'.
getMetaForFilename takes the following arguments:
Returns the metadata for a file give the google drive file id.
getFileMetaData takes the following arguments:
Passes an array of metadata to the completion handler with one entry for each regular file in the path specified.
listFiles takes the following arguments:
FAQs
Wrapper to simplify interaction with google drive apis
The npm package google-drive-wrapper receives a total of 0 weekly downloads. As such, google-drive-wrapper popularity was classified as not popular.
We found that google-drive-wrapper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.