How to show a list of "shared with me" files in Google Picker - google-api

Google Picker is working fine for the user's own Drive, but I want to add the option to see files shared with the user, as per drive.google.com where you have both My Drive and Shared with me:
This is the code that gets closest:
const sharedDocsView = new window.google.picker.DocsView();
sharedDocsView.setEnableDrives(true); // adds Shared Drives
sharedDocsView.setOwnedByMe(false);
sharedDocsView.setMode(window.google.picker.DocsViewMode.LIST);
pickerBuilder.addView(sharedDocsView);
This gets a Shared Drives tab, but it starts out empty:
However, if you start typing in the search field, it then shows any files that match:
Have experimented with the API, but have not found any combination that will just let the user browse their Shared with me files.

TL;DR: Remove .setEnableDrives(true), you just need setOwnedByMe(false).
Explanation: Judging by your screenshot you don't seem to have any Shared Drives. These are not the same as shared files, and they have a different structure:
Shared drives follow different organization, sharing, and ownership models from My Drive.
Shared Drives look like this in your Drive:
When you set the method .setEnableDrives(true) you're telling the Picker to include Shared Drives. This makes it prioritize the view of these Drives and the "Shared with me" files are included only in the "background" as searchable items, since these have very different views that are not compatible with each other. For example, this is what your view looks like for me:
The above view shows the Shared Drive structure but you can still search for your "Shared with me" files. You'll notice that there's also a "Shared with me" tab. I created that view by using only .setOwnedByMe(false). This view doesn't include the Shared Drives, but it shows just the shared files as you want:
The sample code to create these views is this:
const shareddrivesview = new google.picker.DocsView(google.picker.ViewId.DOCS)
.setEnableDrives(true)
.setIncludeFolders(true); // creates just the shared drives view
const sharedwithmeview = new google.picker.DocsView(google.picker.ViewId.DOCS)
.setOwnedByMe(false); // creates just the shared with me view
var picker = new google.picker.PickerBuilder()
.enableFeature(google.picker.Feature.MULTISELECT_ENABLED)
.setDeveloperKey(API_KEY)
.setAppId(APP_ID)
.setOAuthToken(accessToken)
.addView(shareddrivesview)
.addView(sharedwithmeview)
.setCallback(pickerCallback)
.build()
picker.setVisible(true);
Essentially, you don't want to combine setEnableDrives(true) with setOwnedByMe(false) in the same view unless you want users to have to search their shared files manually. You're better off creating separate views for each of them or remove Shared Drive support if you don't plan to use it.
Sources:
Shared Drives
Google Picker reference

Related

Where to save application data in windows?

I am trying to make a windows application. In this application, some files get modified as a user add or delete an entry. I saved these files on the application folder itself.
But After making binary file I installed it, As I try to add a entry it get crashed.
So, I figured out the issue. The windows doesn't allow to modified files inside C:\Program Files.
So, I installed it in other drive and it works. It solved my issue temporarily but I want to know how other application works in windows.
Where do those applications save their data?
I am not talking about some data which get saved in "Documents" but something which is essential need to modified every time user makes change like theme, formates.
No user access is allowed to the "program folder", and that's for good: it is a system folder, and it should only be accessed for system related operations (like installing or uninstalling a program).
There are many places where "program data" can be stored depending on the situation, and QStandardPaths provides access to their paths, according to the category location. What you might be interested in are:
ConfigLocation: Returns a directory location where user-specific configuration files should be written. This may be either a generic value or application-specific, and the returned path is never empty.
AppDataLocation: Returns a directory location where persistent application data can be stored. This is an application-specific directory.
AppLocalDataLocation: As the previous one, but Windows specific.
AppConfigLocation: Returns a directory location where user-specific configuration files should be written. This is an application-specific directory, and the returned path is never empty.
Those paths (along with the others listed in the documentation) can be accessed using the following static methods:
standardLocations(locationType): returns a list of paths for the requested location type, in order of priority (the first is usually the preferred one);
writableLocation(locationType): returns the preferred path for which write access is allowed (usually the first of the standardLocations());
If you need to store the user configuration, you can use QStandardPaths.writableLocation(AppConfigLocation), while if you have some user-specific internal data that is used by the application (email database, document templates, etc) QStandardPaths.writableLocation(AppLocalDataLocation) should be a good choice.
In both cases, those paths may not exist, so you need to ensure that and eventually create them, possibly by using QDir(path):
dataPath = QtCore.QStandardPaths.writableLocation(AppLocalDataLocation)
dataPathDir = QtCore.QDir(dataPath)
if not dataPathDir.exists():
# create the directory (including parent directories if they don't exist);
# that the argument of mkpath is relative to the QDir's object path, so
# using '.' means that it will create the actual dataPath
dataPathDir.mkpath('.')
Note that for all of the above (especially the last 3) it's required that you correctly set both the organizationName and the applicationName.

Xamarin Essentials FileSystem can you save async

Looking into Xamarin essentials and wondering what the purpose of FileSystem is.
I was looking for something that would load and save a file for me async out of the box.
It looks to me and may be I am not understanding the usage that the only thing that it gives you is a location where to save and load the file and there is no functionality to actually save it for you eg "Old PCLStorage"
is this correct?
All Xamarin Essentials File System Helpers are doing is providing access to two different directories within your app, CacheDirectory and AppDataDirectory and access to the read-only pre-bundled files within application so you do not have to write platform-based code for these locations and do your own DI (or use Forms' DI) to access them...
Once you have the string-based directory location, then you use the normal .Net(Std) file and directory I/O routines. Create/delete subdirectories, create/read/write/delete a file using the async (or not) functions from the .Net(Std) framework or a third-party framework/package. Your choice...
CacheDirectory
The cache directory is a read/write location and it implements access to the "native" platform cache location. On Android this is the Cache
var cacheDir = FileSystem.CacheDirectory;
AppDataDirectory
The app data directory is the "default" location for where regular files should be stored.
As the docs state:
any files that are not user data file
FYI: This is not the place to be used for Sqlite databases and such if you are implementing/complying with platform dependent norms... Why Essentials did not include a database location is unknown to me when platforms like iOS and Android have APIs for them and formally documented locations... ;-/
Application bundled files (read-only)
OpenAppPackageFileAsync provides access (via a Stream) to read-only bundled files in your application (AndroidAssets, BundleResource, etc..)
using (var stream = await FileSystem.OpenAppPackageFileAsync("sushiLogo.png"))
{
using (var reader = new StreamReader(stream))
{
var fileContents = await reader.ReadToEndAsync();
}
}

How to make users to download files in Dropbox with Ruby?

I'm now trying to make a function that allows users to access to the link of the file to download.
The native link is https://www.dropbox.com/home/Apps/ringle_records?preview=lesson_id_11%3Auser_id_5.mp3 but, it is only accessible by admin ( for sure ). If I have a user who is eligible to know this link, then I would love to allow this user to click some button to download the file.
I am kind of bogged down when it comes to implementation. Because if I use the below code, it seems it stores data into the server.
def self.dropbox_download
contents, metadata = Drop_client.get_file_and_metadata('/lesson_id_12:user_id_7.mp3.mp3')
begin
File.open('filename.mp3', 'wb') do |file|
file.write(contents)
end
rescue
end
end
I want to make user to click something and the "mp3" file will be downloaded, but I don't think the above code works in this way.
Please shoot any opinion! I'm looking forward to seeing!
Best
If you only need to allow other users to download this specific file (or some specific set of files), the easiest way is to just get a shared link to the relevant file(s):
https://www.dropbox.com/help/167
You can modify these shared links for different behaviors, e.g., for file downloads, as shown here:
https://www.dropbox.com/help/201
If you do need to get these links programmatically, you can use the shares method:
https://dropbox.github.io/dropbox-sdk-ruby/api-docs/v1.6.4/DropboxClient.html#method-i-shares
You can then give the shared link to the user, e.g., as a link on a web page, or in an email, etc.

Google Drive api scope and file access (drive vs drive.files)

I have created two refresh tokens for me:
one for
SCOPE = 'https://www.googleapis.com/auth/drive'
and another
SCOPE = 'https://www.googleapis.com/auth/drive.file'
I'm trying to get information about files (using get method)
Some files I can get when using SCOPE drive.files, and some only when using wider scope drive
But I can not figure out what is the reason for that? Files are located in different folders but have one shared root folder.
The difference is that 'drive.file' only gives you permission to files that your app has created or the user has explicitly shared with your app, whereas 'drive' gives your app permission to see the all the files in the user's drive.
See
https://developers.google.com/drive/web/scopes
You should really look into using drive.file, that is where they are trying to push users. I was just fighting with this myself and found that if you use the drive.file scope, you can then subsequently open the file that is chosen using the API for the file type, but only if you set the correct AppID.
See here: https://developers.google.com/picker/docs/#gdata
This allows you to get past the 404 error that you get if you don't set the AppID.

Dynamic user permission to secure folders in MVC3

Using MVC3 I am trying to come up with method of checking the database to see if a user is allowed access to a folder. The administrator has individual control over each user's permission to courses, so I cannot control this from web.config.
The screenshot below provides an example of what I am trying to accomplish: courseA is an example of one of many folders that only certain users will be allowed access to. My thinking is that I could use a CourseController action like OpenCourse(int id) to check against the db if a user has access to a course, and if so then "allow access" to the entire course folder and open the player.html file contained within it. The user's permission to each file within courseA folder would probably need to persist for the user's session.
Is it even possible to do something like this from within the MVC View folder, or should the courseA folder sit somewhere else?
You can enforce this sort of restriction in your database calls. You could say for example:
var courses = ListCoursesForUser(userId);
Then when accessing a specific course you can reuse this:
public doSomethingWithCourse(courseId, userId)
{
var courses = ListCoursesForUser(userId);
if(courses.Any(c => c.courseId == courseId))
{
}
}

Resources