open drive picker with a known fileId selected - google-picker

In my webapp it can happen that a user imported an owned drive file through a copy-pasted link. At that point I already know the fileId from the link, but I need to ask the user to go through the picker in order to make that file available within the app (I'm using drive.file scope only).
I tried using the View.setQuery(string) api, but I'm not sure it can help.
Is it possible to set a query for a specific fileId? Is there some other way to achieve it?

Related

Google Classroom API: Upload file to "class drive folder" but ensure only teacher can see it

I am using the Google Classroom API to allow students to take tests using our system and send the overall grades back up. That is all working fine.
What I want to do is to create a spreadsheet of the breakdown of student results from our system and upload that either as a CSV or create a Google Spreadsheet. This spreadsheet should only be visible to the teacher(s) of the course.
Is it possible to create a Google Spreadsheet / Drive file which is only visible to the teacher. I was thinking to put it in the course driveFolder but it's not clear to me what the permissions are of that folder. For example, the entire folder could be shared with students and so obviously I don't want to put the results there as they shouldn't be visible to students.
Another possibility might be to upload it to the teachers own drive account, but, that doesn't seem ideal either.
My absolute preference would be to attach it to the "courseWork" item in some teacher-only-visible way, but, it doesn't look like that's an option.
Anyway, sorry for the slightly wooly question, but, if you're doing something like this and have a suggestion I'd love to hear it.
The property teacherFolder from the course resource refers to:
a DriveFolder that is shared with all teachers of the course.
This folder is created when the course itself is created, and by default it is shared with course teachers but not with students, so I think it would be the perfect place to store the spreadsheet. Storing data that is only shared with teachers is this folder's purpose, anyway.
Update: Prevent editors from changing access permissions:
In order to avoid the risk of a folder being shared, the owner of the folder can prevent editors from changing access permissions and sharing the folder with other accounts. Just click the Share button and, in Advanced options, check the Prevent editors from changing access and adding new people box, as explained here.
Of course, the folder owner can still invite new people and change these settings, so I'd suggest you to transfer ownership to a safe account that you are sure 100% won't try to share this folder with students.
Reference:
Classroom API: Courses
Restrict sharing options on Drive files

Share to download

How to make a share to download system?
Means the visitor must share the content on a social network to get the desired file.
eg.W3layouts.com I must share the article to download the file.
NB: No third party solution. I want to know how it work and create a new one
Thank you
I will just use Twitter as an example:
You would use a Twitter web intent to track the user's click on your widget to share whatever content you want shared, seen in this page: https://dev.twitter.com/web/javascript/events . Use the 'tweet' event to listen for when the user interacts with the button. When you've verified that this event has fired, call the function that downloads the file to the user's computer.
Another thing, take to Google before you go asking it on StackOverflow.

Realtime drive javascript example not working - Google API

I set up the Realtime drive example shown here: https://developers.google.com/drive/realtime/realtime-quickstart
On this site: http://shuub.com
But the thing is, that when I access the link from a different browser (logged in a different Google account), it won't load the file.
All I need is to edit some plain text with another user, without needing to access a google account, it doesn't even need to be saved after closing the site. Is it possible?
Thanks for reading.
But the thing is, that when I access the link from a different browser
(logged in a different Google account), it won't load the file.
Probably you need to share the file with the other user first.
Open Google Drive in your Browser. If you did not modify the example code, your file should be located in the root folder. It's probably named "New Realtime Quickstart File". Right-click on the file and share it with the other user by adding his account to the list and granting all permissions.
All I need is to edit some plain text with another user, without
needing to access a google account, it doesn't even need to be saved
after closing the site. Is it possible?
The website you have linked is not reachable so I don't know what you want to do exactly.
Probably you could also use other and (in that use case without saving and login) simpler techniques like Mozillas TogetherJS (you can try it on jsfiddle.net) or you could use a tool like Etherpad.

Sandboxing and security-scoped bookmarks

I'm writing an app which tracks disk usage. For that I let the user select drives (represented as URLs starting with /volume). I save the info using core data. Now I'd like to implement sandboxing and I'm not exactly sure how I'd proceed. There's no out-of-the-box entitlement that gives me access to this path. From what I understand, I'd need to...
Let the user select a specific path (drive) which enables access to those files outside the application directory
In order to make these selected paths persist across app launches, I need to create security-scoped bookmarks.
I think I can save those as NSData in Core Data objects (binary type)
Upon app launch, "resolve" those security scoped bookmarks again to re-gain access.
Does this make sense? Am I missing something here? Any tips/hints you can provide?
Your outline is correct.
To have the user select a drive you can create an NSOpenPanel which starts at /Volumes. You can use a delegate to only allow selection of items within that directory, so even if the user navigates away they won't be able to select anything else. Customise the various messages in the dialog so it becomes a "Select Volume" dialog.
Alternatively you could put up an NSOpenPanel for /Volumes itself - have your user grant you access to that directory. If you do that once and then save a bookmark your user shouldn't be hit by a lot of annoying open dialogs. Once you've got access to /Volumes your app can allow selection of a subset of volumes if it needs to.
Caveat: while gaining access to the whole directory is possible, if you intend to put your app in the App Store you might find that Apple sees you as asking for too much from your users. You might want to start with read-only access to the directory and if they kick that back fall back to selecting individual disks - just be prepared.
You can also store the bookmarks in a plist (within your container) or user defaults, you'll need to decide if those suit better than Core Data.
HTH

saving a document to the internet so it can be shared by other users

I have a working Cocoa app that creates a database file and stores it locally. What I would like to do is store that file on a remove server so that different users of my app at different locations would be sharing the same file. My thought was to store the file on a website or ftp server, such as www.mydomain.com/mydatafile.
Forgetting about issues like two users attempting to access the file simultaneously for the moment, can someone point me to an example of how to property construct the URL to be used?
I'm thinking that it should be a fairly simple process with two parts, the first of which is a cocoa NSURL question, and the second which is really more of a w3 issue:
Create the URL to the file itself, and
Append the username and password require to login to the FTP site.
Any nudges in the right direction would be appreciated!
* edit *
I should mention that the file I would like to be shared by multiple users, is basically several custom objects stored as a file with NSKeyedArchiver...
I suggest you to intgrate your app with some cloud based document storage,sharing,editing service like Google docs/drive.
Until and unless you are going to provide very specific file formats native to your app and are doing something out of ordinary.
Using something like this would save you time, and user wont have to create yet another login-id.

Resources