Google Drive Picker - select folders to upload - google-api

I have my picker code as follows:
var mimetypes = "application/vnd.ms-excel," +
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet," +
"application/vnd.google-apps.spreadsheet," +
"application/vnd.ms-powerpoint," +
"application/vnd.openxmlformats-officedocument.presentationml.presentation," +
"application/vnd.google-apps.presentation," +
"application/vnd.openxmlformats-officedocument.wordprocessingml.document," +
"application/msword," +
"application/vnd.google-apps.document," +
"application/pdf,"+
"application/vnd.google-apps.folder";
var view = new google.picker.View(google.picker.ViewId.DOCS);
view.setMimeTypes(mimetypes);
var docsView = new google.picker.DocsView()
.setIncludeFolders(true)
.setMimeTypes('application/vnd.google-apps.folder')
.setSelectFolderEnabled(true);
var folderView = new google.picker.View(google.picker.ViewId.FODLERS);
folderView.setMimeTypes("application/vnd.google-apps.folder");
var picker = new google.picker.PickerBuilder()
.enableFeature(google.picker.Feature.MINE_ONLY)
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.setAppId(appId)
.setOAuthToken(oauthToken)
.addView(view)
.addView(docsView)
.addView(folderView)
.addView(new google.picker.DocsUploadView())
.setSelectableMimeTypes(mimetypes)
.setDeveloperKey(developerKey)
.setCallback(pickerCallback)
.build();
picker.setVisible(true);
I have added the view to enable "setSelectFolderEnabled" but still after selecting the folder form Picker View, the "Select" button in the bottom remains disabled. I need the folder Id in callback for further processing. But I am unable to figure out how to enable the button even if a folder is selected.
Does Google Picker API only allow to select files saved in Google Drive ??

Just changed my code to this and it works :
var docsView = new google.picker.DocsView().
setIncludeFolders(true).
setSelectFolderEnabled(true);
var picker = new google.picker.PickerBuilder()
.enableFeature(google.picker.Feature.MINE_ONLY)
.enableFeature(google.picker.Feature.NAV_HIDDEN)
.setAppId(appId)
.setOAuthToken(oauthToken)
.setDeveloperKey(developerKey)
.addView(docsView)
.setCallback(pickerCallback)
.build();
picker.setVisible(true);

Try to add the google.picker.​ViewId.FOLDERS viewId in the addView. I think you can't select folders due to it not being set in the PickerView.Builder. More information about the View Descriptions can be found on the Showing Different Views of the Picker API documentation.
After that, determine if you have write scopes for you to upload files to Drive.

Related

How to list a single filetype in google picker

I want to only show files of a certain type (e.g. Spreadsheets). Is this possible?
I would have thought that specifying picker.ViewId.SPREADSHEETS would accomplish this but it appears not.
const {DocsView, DocsViewMode} = picker
var view = new DocsView(picker.ViewId.SPREADSHEETS)
view.setMimeTypes("image/png,image/jpeg,image/jpg")
view.setMode(DocsViewMode.LIST)
view.setSelectFolderEnabled(false)
var picker = new picker.PickerBuilder()
.enableFeature(picker.Feature.NAV_HIDDEN)
.setAppId(appId)
.setOAuthToken(oauthToken)
.setDeveloperKey(developerKey)
.setCallback(resolve)
.addView(view)
.build()
picker.setVisible(true)

How can I auto save a captured image in a UWP app?

I have this code:
CameraCaptureUI captureUI = new CameraCaptureUI();
captureUI.PhotoSettings.AllowCropping = false;
StorageFile photo = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo);
How can I implement to auto save image option when click on the capture button?
How can I implement to auto save image option when click on the capture button?
The StorageFile containing the captured photo is given a dynamically generated name and saved in our app's local folder if we do not cancel the capture, so if we click on the capture button without clicking the confirm button, the photo will be saved automatically in our app's TempState folder.
For more info, refer Capture photos and video with Windows built-in camera UI.
To better organize your captured photos, you may want to move the file to a different folder. Please refer to the following sample which shows how to copy the latest capture photo from the TempState folder to the LocalFolder.
For example:
CameraCaptureUI captureUI = new CameraCaptureUI();
captureUI.PhotoSettings.AllowCropping = false;
StorageFile photo = await captureUI.CaptureFileAsync(CameraCaptureUIMode.Photo);
Windows.Storage.StorageFolder localFolder = Windows.Storage.ApplicationData.Current.TemporaryFolder;
var allFiles =await localFolder.GetFilesAsync();
foreach (StorageFile item in allFiles.OrderByDescending(a => a.DateCreated))
{
StorageFolder destinationFolder = await ApplicationData.Current.LocalFolder.CreateFolderAsync("ProfilePhotoFolder", CreationCollisionOption.OpenIfExists);
await item.CopyAsync(destinationFolder, DateTimeOffset.Now.ToString("yyyyMMddHHmmssfff") + ".jpg", NameCollisionOption.ReplaceExisting);
await item.DeleteAsync();
return;
}

Adding CameraOverlayView to UIImagePicker

I am stuck in creating a CameraOverlayView on the UIImagePicker my Xamarin.iOS application
here is my code to launch the cameraView
{
var imagePickerControl = new UIImagePickerController();
imagePickerControl.SourceType = UIImagePickerControllerSourceType.Camera;
imagePickerControl.ShowsCameraControls = false;
//imagePickerControl.CameraOverlayView = new CameraOverlayView();
var imagePickerDelegate = new CameraImagePicker(this);
imagePickerControl.Delegate = imagePickerDelegate;
NavigationController.PresentModalViewController(imagePickerControl, true);
}
the above code helped me creating a imagepicker with no controls...
can somebody help me creating a CameraOverlayview :UIView
I m trying to create a custom UI and basic controls (with 2 imagebuttons and UI like its in instagram Camera screen)

The server unable to resolve the link MVC application

I am currently working on a kendo ui tab. It contains tab1,tab2,tab3.
The first tab has the kendo ui grid which worked fine. What I am trying to do is when a user selects a record on tab 1, tab 2 , or tab 3 it will be enabled with data populated from controller.
here is the code:
function onChange() {
var grid = $("#product").data("kendoGrid"); ;
var selected = grid.select();
if (selected.length) {
var data = grid.dataItem(selected);
var trn= data.TRN;
$($('#tabstrip').find('a.k-link')[3]).data('contentUrl', 'TestPlan?TRN=' + hrn);
$($('#tabstrip').find('a.k-link')[2]).data('contentUrl', 'Summary?TRN=' + hrn);
var ts = $('#tabstrip').data("kendoTabStrip");
ts.reload(ts.tabGroup.children("li")[3]);
ts.reload(ts.tabGroup.children("li")[2]);
ts.enable(ts.tabGroup.children("li")[3]);
ts.enable(ts.tabGroup.children("li")[2]);
}
}
Testing:
If I use Chrome to inspect the error that they could not find the link of tab 2 and tab 3
So I suspect that my url content not format properly because it works in the local environment but not in the server
So how I could modify the following link using URL.content?
$($('#tabstrip').find('a.k-link')[3]).data('contentUrl', 'TestPlan?TRN=' + trn);
$($('#tabstrip').find('a.k-link')[2]).data('contentUrl', 'Summary?TRN=' + trn);
try to use this syntax : '/TestPlan?TRN='
i found it:
$($('#tabstrip').find('a.k-link')[1]).data('contentUrl', '#(Url.Content("~/TestPlan?TRN="))' + trn);

CKEditor editor instance .lang is undefined?

Hi I am trying to make some changes to our implementation of CKEDITOR 3.6.2
by removing all but 2 options in the link target type dropdown that appears in the link dialog's target tab.
I tried to achieve this using the API but I am getting an error in the minified core ckeditor.js file in the dialog() method on this line X=S.lang.dir; where S is the editor.
The .lang property of the editor instance is undefined when doing CKEDITOR.dialog(editor, 'link'), when viewing debugging the "editor" object I don't see a lang object anywhere, so I'm not sure why this is missing? I didn't work on our original implementation but as far as I know we have only added 2 plugins and not changed the ckeditor core.
Here is my code:
for (var i in CKEDITOR.instances) {
var editor = CKEDITOR.instances[i];
var dialogObj = CKEDITOR.dialog(editor, 'link');
var linkDialogTargetField = dialogObj.getContentElement('target', 'linkTargetType');
// API didn't seem to have a more efficient approach than clearing all and re-adding the one we want
linkDialogTargetField.clear();
linkDialogTargetField.add('notSet', '<not set>');
linkDialogTargetField.add('_blank', 'New Window (_blank)');
}
I have managed to make my change without using the API properly by doing the below:
CKEDITOR.on('dialogDefinition', function (ev) {
// Take the dialog name and its definition from the event
// data.
var dialogName = ev.data.name;
var dialogDefinition = ev.data.definition;
// Check if the definition is from the dialog we're
// interested on (the "Link" dialog).
if (dialogName == 'link') {
// Get a reference to the "Link target" tab.
var targetTab = dialogDefinition.getContents('target');
var targetField = targetTab.get('linkTargetType');
// removing everything except the 1st (none set) & 3rd (new window) options from the dropdown
targetField['items'].splice(1, 2);
targetField['items'].splice(2, 3); // the array is reduced by splice, so we have to splice from [2] onwards not from [4]
}
});
but I don't like this approach, does anyone have any ideas? or other ways to achieve the same result using the API?
Using second approach and overwritten the dropdown items instead of splicing.

Resources