Last active
June 5, 2023 09:29
-
-
Save akingdom/55dc8cf6155444dfef781cefbb7da7e3 to your computer and use it in GitHub Desktop.
Code snippet to transform a Google Drive link to a directly accessible URL (2023)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Try transforming a shared link from Google Drive to a Google Drive raw link. | |
// | |
// Caveat - this is to show what needs replacing - ideally the replace should be done via REGEX or similar if more flexibility is needed. | |
// MIT license - Copyright Andrew Kingdom 2023 all rights reserved. | |
// | |
// | |
- (void)example { | |
NSString serverDataURLString = @"...yourgoogledriveurl..."; | |
serverDataURLString = [serverDataURLString stringByReplacingOccurrencesOfString: | |
@"https://drive.google.com/file/d/" withString: | |
@"https://drive.google.com/uc?export=download&id="]; | |
serverDataURLString = [serverDataURLString stringByReplacingOccurrencesOfString: | |
@"/view?usp=share_link" withString: | |
@""]; | |
// ...do something... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment