Google Docs have a "Download as..." menu option, with several choices of format such as PDF, text, etc.
How can I programmatically download a particular Google document?
From how to programmatically download a public Google Drive file?:
You don't need any Google SDK if you know the link and the file is public. Just use a standard HTTP GET method to download the file.
Example with AngularJS:
$http.get('/doc_url').
then(function(response) {
// this callback will be called asynchronously
// when the response is available
}, function(response) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
Related
Is a React Native app and i use #react-native-firebase/dynamic-links version 7.1.0 (rnFirebase).
On android my dynamic link work correctly.
On ios with firebase test link work correctly (myUrl.page.link), but with a verified prefix url (myUrl) app are opened but my function dynamicLinks().getInitialLink() return null.
(I have add correctly url on associated domains in xcode)
I created the link with
const link = await dynamicLinks().buildShortLink(
{
link: encodeURI(
`myUrl/${list.generatedString}`
),
domainUriPrefix: 'myUrl',
analytics: {
campaign: 'banner'
},
navigation: {
forcedRedirectEnabled: false,
},
ios: {
bundleId: 'com.runeapp.gift-it',
// customScheme: 'giftit',
appStoreId: '1503678456'
},
android: {
packageName: 'com.runeapp.giftit'
}
},
'SHORT'
);
I wonder if the problem can be derived from the fact that the app has not yet been published on the app store.
Anyone have any idea?
thanks
dynamicLinks().getInitialLink() doesn't seem to work on iOS but here is a simple workaround I used in solving that:
When a user is on an iOS device, use the Linking package in react-native, then use the dynamicLinks().resolveLink() passing the URL returned from Linking. getInitialURL(), which would return the same response as dynamicLinks().getInitialLink(). Here is a snippet:
if (Platform.OS === 'ios') {
Linking.getInitialURL()
.then(res => {
dynamicLinks().resolveLink(res).then(response => {
console.log(response.url);
})
})
}
You could use the value from the Linking library directly but it is helpful to call the dynamic link resolveLink() in case you added extra parameters while building your link.
My issue was because I'm using API key restriction for the API key I use in my application. I extended the restriction to allow usage with the Firebase Dynamic Links API.
To allow your API key in question to be used with the new Firebase Dynamic Links API:
go to the Google Cloud Console
choose the relevant project (i.e. the project you use for your application)
open the menu and go to APIs & Services -> Credentials
click Edit API key for the API key in question
scroll down to API restrictions section
from the dropdown, choose Firebase Dynamic Links API
click Save
wait a couple of minutes for Google servers to update and retry...
When you open the app from the background you need to call onLink instead of getInitialLink
I am trying to upload a picture to a channel using the code in this link:
const formData = new FormData();
formData.append('file', $('#formInputFile')[0].files[0]);
// get desired channel (for example, with getChannelBySid promise)
chatClient.getChannelBySid(channelSid).then(function(channel) {
// send media with all FormData parsed atrtibutes
channel.sendMessage(formData);
});
File is uploaded and image is shared successfully, but i would like to show upload progress to the user. How can i do it?
Also, while displaying images, is there a way to get thumbnail of the image first so as to not download the entire image unless user wants to see it?
No examples of the upload progress code is provided in Github sample project.
Twilio developer evangelist here.
I'm afraid that it is currently not possible to get progress events with the JavaScript API. Also, there is no thumbnails of images available either, you can get the image URL using message.media.getContentUrl() and that only resolves the promise with a single URL and doesn't take options.
Whenever I upload an image to Firebase Storage, the file is only accessible through "download link".
What if I want anyone to access this file?
If I go to Google Platform Storage and enter the same bucket that Firebase uses, I can see that the "Public link" is unchecked.
How can I let this be automatically checked when photo has been uploaded?
Such actions can be done through Google Cloud Storage API, but there doesn't seem to be any option for this through Firebase.
Also, all images that are being uploaded via Firebase has a Content-Type of "application/octet-stream".
Since I am uploading an image, I would like this to have either "image/jpeg" or "image/png". Is there a way to change the metadata?
UPDATE: Reason why I am asking this is because if one create an app with an Instagram like feed of thousands of images. Requesting a download link for each image that is being fetched is unnecessary since the images in questions should already be open to public by default. Firebase file upload prevents this and each user therefor has to make one request per image (which can be tons of images per app launch). Firebase Flame subscription plan for instance has a limit of 100,000 downloads/uploads per month. This makes it unrealistic to create an image feed with thousands of users with thousands of image request each. Files should have the option to create a public link during upload, just as the Google Cloud Storage API itself.
There is no configuration to automatically check the public access checkbox of Google Cloud Storage for files that are uploaded through Firebase Storage.
That said, you could write a Google Cloud Function that triggers when a file is uploaded and that then changes the properties of the file, specifically, you'll want to change the object ACLs to be publicRead.
But since the download URL that Firebase generates for you is already publicly readable, I'm not sure what you gain by checking the box. Is there a specific use-case that you're looking for that isn't covered by simply sharing the download URL?
On the second part of your question, check out the File Metadata section of our docs, which shows you how to set the content type of a file:
// Create file metadata to update
FIRStorageMetadata *newMetadata = [[FIRStorageMetadata alloc] init];
newMetadata.contentType = #"image/jpeg";
// Update metadata properties
[myRef updateMetadata:newMetadata completion:^(FIRStorageMetadata *metadata, NSError *error){
if (error != nil) {
// Uh-oh, an error occurred!
} else {
// Updated metadata for 'images/forest.jpg' is returned
}
}];
Metadata can on added on upload as well, so there's no need for a second request.
Inside of my app, I would like the user to be able to log into DropBox, and browse and view his or her files and folders. This seems like a very common task to me, so I'm wondering if there are any tutorials or sample code out there? I haven't been able to find anything on Google.
I believe I could do it myself using a table view and the Core API tutorial from dropbox.com, but I don't want to waste all that time if the code is already out there.
if you are looking it on Objective c you can get a demo project from this link. where you can browse the folder of rootdirectory and also you can download the files.
https://github.com/danielbierwirth/DropboxBrowser
I had the same problem. It took me so long to find the answer for that, really it was overwhelming because there isn't much info about it. I did this:
I'm sorry for my english, is not my first language.
Install Dropbox Chooser https://www.dropbox.com/developers/chooser#ios
Install SwiftyDropbox
SwiftyDropbox installs Alamofire, we need this to download the file, if not then install it
Dropbox Chooser allow the user select any file from their dropbox account and returns the shared link of the selected file so:
//Ask SwiftyDropbox if the user is logged in
if DropboxClientsManager.authorizedClient != nil{
// Use this from Dropbox chooser to open a view controller that allow the user select the file
//DBChooserLinkTypeDirect <--- it has to be this parameter, there is another one but is useless for our purpose
DBChooser.default().open(for: DBChooserLinkTypeDirect, from: self, completion: { (results) in
//Here starts the completion block of Chooser
if let resultado = results{ //Obtain the results
var d = DBChooserResult() //Create a variable of DBChooserResult type
d = resultado[0] as! DBChooserResult //Get the result. Just one result because the user just can select ONE file (in this version just one, it may be more but I don't know how in this moment
print(d.name)
print(d.link)//The atributte link give us the url to download the file.
//If you paste it in your browser the download starts right away
//Use Alamofire to download the file from the url
Alamofire.request(d.link).responseData { response in
//Get the data from the URL
if let data = response.result.value
{
//Here we have the data to do whatever we want, in my case I show the PDF file in a WebView
print("Data de Alamofire \(response.description)")
self.desplegarUrlEnWebview(datos: data, url: d.link)
}
}
}
})
}else{
//If the user is not logged in we use SwiftyDropbox to log in
DropboxClientsManager.authorizeFromController(UIApplication.shared, controller: self, openURL: { (url) in
UIApplication.shared.open(url, options: [:], completionHandler: nil)
})
}
All of the official resources for the Dropbox API and SDKs can be found on the Dropbox Developer website:
https://www.dropbox.com/developers
Specifically, you're referring to the iOS Core SDK. You already mentioned the tutorial, but the SDK download itself also contains a working sample app:
https://www.dropbox.com/developers/core/sdks/ios
The sample doesn't contain all of the functionality you're looking for though.
Well, I've gone ahead and created it. Although it seems to have a problem when trying to view a pdf file. Anyway, here is the code:
https://github.com/danielbierwirth/DropboxBrowser
and for more inforation you can refer to official developer site of dropbox.
Use pod 'SwiftyDropbox'.
Configure your project as explained here: http://dropbox.github.io/SwiftyDropbox/api-docs/latest/.
In your Dropbox App console remember to give Permissions that allow your app to view and manage files and folders under Permission tab. You have to regenerate the access token if you make any changes in the permission and remember to change the access token in your code.
Since dropbox doesn't has a redirect url to redirect and view our files & folders after we login, we have to create a table view controller to load our files with the metadata. (Remember, you have to return back to your app from dropbox to view the files).
If you want to use the file for uploading purpose in your app, do it with tableView delegate method 'didSeelectRowAt'.
Specifically, I would like to share granular page content via triggering the iOS share sheet with in-page buttons.
In my webapp page, I have a table of downloadable PDFs. I would like to be able to add a column called "Share" into the table, so that a button could be tapped to share the URL to that document, without having to open the document itself and share from there.
In order to do this, I assume I would need to customise this triggered share sheet to share a different URL to the one that is showing in mobile safari's address bar.
Is this possible using javascript, or alternative URLs in a meta tag maybe? I don't expect URL scheme to be a solution, as it is concerned with sending data to another application.
Addendum 6/2020 It is possible since iOS 12.4, it works great.
It will be supported in Safari iOS V12.2. The beta of V12.2 already has it.
There's a good article by Maximiliano Firtman on a number of new features that will be possible in the new version.
Not currently on ios but a new w3c spec is on the way called web share api. Currently only available in chrome for android behind a origin trail.
https://developers.google.com/web/updates/2016/10/navigator-share
Yes, via the Web Share API
per the w3 docs:
shareButton.addEventListener("click", async () => {
try {
await navigator.share({ title: "Example Page", url: "" });
console.log("Data was shared successfully");
} catch (err) {
console.error("Share failed:", err.message);
}
});
Great article by Joe Medley on web.dev: Integrate with the OS sharing UI with the Web Share API