private async void UploadFileAsync()
        {
            m_IsUploading = true;
            m_FileId      = "";
            m_FileURL     = "";

            await Task.Run(() =>
            {
                m_FileId  = DriveAPI.UploadFile(m_MediaType, m_UploadName, m_FilePath);
                m_FileURL = DriveAPI.GetFileURL(m_FileId);
            });

            Repaint();
            m_IsUploading = false;
        }
Exemple #2
0
        protected override void ContextClickedItem(int id)
        {
            base.ContextClickedItem(id);

            GenericMenu menu = new GenericMenu();

            menu.AddItem(new GUIContent("ファイルを開く"), false, () =>
            {
                var item    = (FileTreeViewItem)GetRows()[id];
                var openURL = DriveAPI.GetFileURL(item.FileId);
                System.Diagnostics.Process.Start(openURL);
            });
            menu.AddItem(new GUIContent("ファイルをダウンロード"), false, () =>
            {
                DownloadFileAsync(id);
            });
            menu.AddSeparator("");

            menu.AddItem(new GUIContent("コピー/ID"), false, () =>
            {
                var item = (FileTreeViewItem)GetRows()[id];
                GUIUtility.systemCopyBuffer = item.FileId;
            });
            menu.AddItem(new GUIContent("コピー/MimeType"), false, () =>
            {
                var item = (FileTreeViewItem)GetRows()[id];
                GUIUtility.systemCopyBuffer = item.MimeType;
            });
            menu.AddSeparator("");

            menu.AddItem(new GUIContent("ファイルを削除"), false, () =>
            {
                var ids = GetSelection();
                bool ok = EditorUtility.DisplayDialog(
                    "ファイルの削除",
                    GetDeleteDialogMessage(ids),
                    "削除する", "やめる"
                    );
                if (!ok)
                {
                    return;
                }

                DeleteAsync(ids);
            });

            menu.ShowAsContext();
        }
Exemple #3
0
        private async void UploadFileAsync()
        {
            m_IsUploading = true;
            m_FileId      = "";
            m_FileURL     = "";

            var filePath = AssetDatabase.GetAssetPath(m_UploadAsset);
            await Task.Run(() =>
            {
                var mediaType = MediaSettings.GetMediaFromPath(filePath);
                m_FileId      = DriveAPI.UploadFile(mediaType, m_UploadName, filePath);
                m_FileURL     = DriveAPI.GetFileURL(m_FileId);
            });

            Repaint();
            m_IsUploading = false;
        }