m-files-api 相关问题


代码:“CLOUD_AGENT_FORBIDDEN”Dropbox 下载

发布 https://content.dropboxapi.com/2/files/download 错误:您已达到云代理使用限制 网络 请求标头 授权:承载 sl.xxxxxxx dropbox-api-arg: {"路径": &


通过更少的 Java API 调用来映射 Google 云端硬盘内容的有效方法

大家好,我有一个代码,用于列出共享驱动器中存在的文件(以便稍后下载并创建相同的文件夹路径) 目前我做这样的事情: 哈希映射 大家好,我有一个代码,用于列出共享驱动器中存在的文件(以便稍后下载并创建相同的文件夹路径) 目前我正在做这样的事情: HashMap<String, Strin> foldersPathToID = new HashMap<>(); //searching all folders first saving their IDs searchAllFoldersRecursive(folderName.trim(), driveId, foldersPathToID); //then listing files in all folders HashMap<String, List<File>> pathFile = new HashMap<>(); for (Entry<String, String> pathFolder : foldersPathToID.entrySet()) { List<File> result = search(Type.FILE, pathFolder.getValue()); if (result.size() > 0) { String targetPathFolder = pathFolder.getKey().trim(); pathFile.putIfAbsent(targetPathFolder, new ArrayList<>()); for (File file : result) { pathFile.get(targetPathFolder).add(file); } } } 递归方法在哪里: private static void searchAllFoldersRecursive(String nameFold, String id, HashMap<String, String> map) throws IOException, RefreshTokenException { map.putIfAbsent(nameFold, id); List<File> result; result = search(Type.FOLDER, id); // dig deeper if (result.size() > 0) { for (File folder : result) { searchAllFoldersRecursive(nameFold + java.io.File.separator + normalizeName(folder.getName()), folder.getId(), map); } } } 搜索功能是: private static List<com.google.api.services.drive.model.File> search(Type type, String folderId) throws IOException, RefreshTokenException { String nextPageToken = "go"; List<File> driveFolders = new ArrayList<>(); com.google.api.services.drive.Drive.Files.List request = service.files() .list() .setQ("'" + folderId + "' in parents and mimeType" + (type == Type.FOLDER ? "=" : "!=") + "'application/vnd.google-apps.folder' and trashed = false") .setPageSize(100).setFields("nextPageToken, files(id, name)"); while (nextPageToken != null && nextPageToken.length() > 0) { try { FileList result = request.execute(); driveFolders.addAll(result.getFiles()); nextPageToken = result.getNextPageToken(); request.setPageToken(nextPageToken); return driveFolders; } catch (TokenResponseException tokenError) { if (tokenError.getDetails().getError().equalsIgnoreCase("invalid_grant")) { log.err("Token no more valid removing it Please retry"); java.io.File cred = new java.io.File("./tokens/StoredCredential"); if (cred.exists()) { cred.delete(); } throw new RefreshTokenException("Creds invalid will retry re allow for the token"); } log.err("Error while geting response with token for folder id : " + folderId, tokenError); nextPageToken = null; } catch (Exception e) { log.err("Error while reading folder id : " + folderId, e); nextPageToken = null; } } return new ArrayList<>(); } 我确信有一种方法可以通过很少的 api 调用(甚至可能是一个调用?)对每个文件(使用文件夹树路径)进行正确的映射,因为在我的版本中,我花了很多时间进行调用 service.files().list().setQ("'" + folderId+ "' in parents and mimeType" + (type == Type.FOLDER ? "=" : "!=") + "'application/vnd.google-apps.folder' and trashed = false").setPageSize(100).setFields("nextPageToken, files(id, name)"); 每个子文件夹至少一次......并且递归搜索所有内容需要很长时间。最后,映射比下载本身花费的时间更多...... 我搜索了文档,也在此处搜索,但没有找到任何内容来列出具有一个库的所有驱动器调用任何想法? 我想使用专用的 java API 来获取共享 GoogleDrive 中的所有文件及其相对路径,但调用次数尽可能少。 提前感谢您的时间和答复 我建议您使用高效的数据结构和逻辑来构建文件夹树并将文件映射到其路径,如下所示 private static void mapDriveContent(String driveId) throws IOException { // HashMap to store folder ID to path mapping HashMap<String, String> idToPath = new HashMap<>(); // HashMap to store files based on their paths HashMap<String, List<File>> pathToFile = new HashMap<>(); // Fetch all files and folders in the drive List<File> allFiles = fetchAllFiles(driveId); // Build folder path mapping and organize files for (File file : allFiles) { String parentId = (file.getParents() != null && !file.getParents().isEmpty()) ? file.getParents().get(0) : null; String path = buildPath(file, parentId, idToPath); if (file.getMimeType().equals("application/vnd.google-apps.folder")) { idToPath.put(file.getId(), path); } else { pathToFile.computeIfAbsent(path, k -> new ArrayList<>()).add(file); } } // Now, pathToFile contains the mapping of paths to files // Your logic to handle these files goes here } private static List<File> fetchAllFiles(String driveId) throws IOException { // Implement fetching all files and folders here // Make sure to handle pagination if necessary // ... } private static String buildPath(File file, String parentId, HashMap<String, String> idToPath) { // Build the file path based on its parent ID and the idToPath mapping // ... }


Android API 33 - 如何获取外部存储的读/写权限?

我正在努力更新现有的 Android 应用程序。该应用程序提供了将自定义文件(例如 PDF 报告、无图像、音频或视频)存储到外部存储“Documents/M...”上的“文档”文件夹的功能


TypeError:WebDriver.__init__() 获得意外的关键字参数“chrome_options”

从 selenium 导入 webdriver 从 selenium.webdriver.chrome.options 导入选项 选项 = 选项() options.binary_location = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe&...


Cuda Tensor Core:矩阵大小仅为 16x16

我有这个非常简单的代码来将两个矩阵与 Cuda Tensor Core 相乘 constexpr int M = 16; constexpr int N = 16; constexpr int K = 16; /* * 矩阵 A = M x N,B = N x K,C = M x K => ...


Microsoft.VisualStudio..Default.props”未找到

我一直在四处寻找,但我得到的是类似的东西 找不到导入的项目“C:...\Microsoft.Cpp.Default.props”, 代替 “C:\Program Files (x86)\MSBuild\Microsoft\VisualStud...


ShellExecuteW 中的 cmd 命令

我想使用cmd注释删除文件。我从 EA 中以 MQL5 语言运行代码。这是我使用的代码 字符串 PathReportBacktest=sTerminalTesterDataPath+"\MQL5\Files\Reports\&q...


使用 VS Code 提供额外的配置文件

我们如何使用 Visual Studio Code 使用 https://github.com/ballerina-platform/ballerina-spec/blob/master/configurable/spec.md# located-toml-files 中指定的多个 .toml 文件? (假设...


在Python中循环时更新列表时出错

为什么列表“spans”从未更新?我无法弄清楚为什么代码会陷入无限循环。 PDF:https://www.sil.org/system/files/reapdata/62/99/18/


XCode 15 没有这样的模块'__ObjC'

当我运行 pod install 时,这些磨损就会出现。 [!] Runner [Debug] 目标会覆盖 Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig 中定义的 ENABLE_BITCODE 构建设置。这……


十进制整数文字中不允许有前导零

我收到此错误: 回溯(最近一次调用最后一次): 文件“/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py”,第 31 行,位于 开始(fakepyfile,mainpy...


如何使用FastAPI实时POST数据?

我使用 FastAPI 构建了一个简单的演示项目。我想实时将数据 POST 到服务器(也许 30fps)。 客户端: 而真实: .... res = requests.post(URL, files={'input_data' :


Azure 存储模拟器问题

我在我的计算机上安装了 Azure 模拟器。然后尝试运行启动批处理,但失败并出现以下错误 C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator>


Node Sass 版本 9.0.0 与 ^4.0.0 不兼容

我的应用程序中没有安装node-sass或sass包。但我一直收到这个错误 ./src/scss/styles.scss 中的错误(./node_modules/@angular-devkit/build-angular/src/angular-cli-files/plu...


DynamoDB 本地基本 PHP 设置

我在连接到本地 DynamoDB 实例时遇到一些问题。我通过在命令提示符下运行以下命令来启动服务器: C:\Program Files\Java\jre8 in>java -Djava.library.


makefile 中的命令前面有反斜杠

在makefile中的命令前添加反斜杠有什么作用? 例如 本例中的 m 命令: # LaTeX Makefile 文件=报告 全部:$(FILE).pdf .PHONY:干净 干净的: m *.aux...


如何将图像序列输入到卷积层并在之后应用 conv-lstm 单元?

我目前正在尝试实现以下论文:https://research.nvidia.com/sites/default/files/publications/dnn_denoise_author.pdf 我在调整网络方面遇到了麻烦,目前


转换时间

我正在尝试将 %Y%m%d%H%M%S%Z 格式的证书到期日期转换为纪元,该日期将用于与从 Java 密钥库收集的另一个日期进行比较。为了保持它相当...


Osquery自定义路径安装窗口,有没有办法修改“Pidfile”和“osquery.db”的路径?

我尝试通过将默认 osquery 安装中的 osqueryd.exe 文件放入 C:\Program Files\Test oo estosqueryd.exe 来在自定义位置安装 osquery。然而,当我安装时...


如何一致地打印时间增量(即格式化)

我有这段代码可以打印以毫秒为单位的时间差。 #!/usr/bin/python 导入日期时间 导入系统 date1= datetime.datetime.strptime('20231107-08:52:53.539', '%Y%m%d-%H:%M:%S.%f') 日期2=


如何在 Big Query 中使用下一个非空 LEAD 值?

我想选择下一个非空引导场景_时间戳。我尝试了以下方法,但收到“从 BOOL 到 TIMESTAMP 的转换无效”错误。 格式时间戳( '%Y-%m-%d %H:%M...


从命令窗口将 .m 文件转换为 .mlx 文件

我知道 .m 文件(特别是函数文件)可以通过右键单击文件并选择“作为实时脚本打开”来转换为 .mlx 文件(保留代码注释和格式)。 是吗


从 App Designer 到通用 .m 脚本文件的变量传输

我正在尝试将字符串(文件位置)从App Designer传输到.m脚本文件。 到目前为止,在应用程序设计器中我有: app.matfile = app.matfileEditField.Value; 应用程序目录=应用程序。


Python 程序中将罗马数字转换为整数时出错

def romanToInt(self, s: str) -> int: 数量 = 0 lst = ["I","V","X","L","C","D","M"] dict = {“我&quo...


无法构建或发布应用程序 maui,有很多错误

我的应用程序在启动时在 IOS 和 Android 上运行良好,但是当我尝试在 Android 上发布应用程序时,我收到所有这些错误: android 应用程序 .net maui 1>C:\Program Files\Microsoft Visual Studio�2\


如何查找给定的键是否存在于 std::map 中

我正在尝试检查给定的键是否在地图中,但有些无法做到: typedef 映射::迭代器 mi; 地图米; m.insert(make_pair("f","++--")); 一对 我正在尝试检查给定的键是否在地图中,但有些做不到: typedef map<string,string>::iterator mi; map<string, string> m; m.insert(make_pair("f","++--")); pair<mi,mi> p = m.equal_range("f");//I'm not sure if equal_range does what I want cout << p.first;//I'm getting error here 那么我怎样才能打印p中的内容呢? 使用 map::find 和 map::end: if (m.find("f") == m.end()) { // not found } else { // found } 要检查映射中是否存在特定键,请通过以下方式之一使用 count 成员函数: m.count(key) > 0 m.count(key) == 1 m.count(key) != 0 map::find的文档说:“另一个成员函数map::count可用于仅检查特定键是否存在。” map::count的文档说:“因为地图容器中的所有元素都是唯一的,所以该函数只能返回1(如果找到该元素)或零(否则)。” 要通过您知道存在的键从映射中检索值,请使用 map::at: value = m.at(key) 与 map::operator[] 不同,如果指定的键不存在,map::at 不会在映射中创建新键。 C++20 为我们提供了 std::map::contains 来做到这一点。 #include <iostream> #include <string> #include <map> int main() { std::map<int, std::string> example = {{1, "One"}, {2, "Two"}, {3, "Three"}, {42, "Don\'t Panic!!!"}}; if(example.contains(42)) { std::cout << "Found\n"; } else { std::cout << "Not found\n"; } } 您可以使用.find(): map<string,string>::iterator i = m.find("f"); if (i == m.end()) { /* Not found */ } else { /* Found, i->first is f, i->second is ++-- */ } C++17 通过带有初始化器的 If 语句进一步简化了这一点。 这样你就可以鱼与熊掌兼得了。 if ( auto it{ m.find( "key" ) }; it != std::end( m ) ) { // Use `structured binding` to get the key // and value. const auto&[ key, value ] { *it }; // Grab either the key or value stored in the pair. // The key is stored in the 'first' variable and // the 'value' is stored in the second. const auto& mkey{ it->first }; const auto& mvalue{ it->second }; // That or just grab the entire pair pointed // to by the iterator. const auto& pair{ *it }; } else { // Key was not found.. } m.find == m.end() // not found 如果您想使用其他API,请找到m.count(c)>0 if (m.count("f")>0) cout << " is an element of m.\n"; else cout << " is not an element of m.\n"; 我想你想要map::find。如果 m.find("f") 等于 m.end(),则未找到密钥。否则,find 返回一个指向找到的元素的迭代器。 错误是因为p.first是一个迭代器,它不适用于流插入。将最后一行更改为 cout << (p.first)->first;。 p 是一对迭代器,p.first 是迭代器,p.first->first 是键字符串。 一张地图对于给定的键只能有一个元素,所以 equal_range 不是很有用。它是为映射定义的,因为它是为所有关联容器定义的,但它对于多重映射更有趣。 template <typename T, typename Key> bool key_exists(const T& container, const Key& key) { return (container.find(key) != std::end(container)); } 当然,如果你想变得更奇特,你可以随时模板化一个函数,该函数也采用已找到的函数和未找到的函数,如下所示: template <typename T, typename Key, typename FoundFunction, typename NotFoundFunction> void find_and_execute(const T& container, const Key& key, FoundFunction found_function, NotFoundFunction not_found_function) { auto& it = container.find(key); if (it != std::end(container)) { found_function(key, it->second); } else { not_found_function(key); } } 并像这样使用它: std::map<int, int> some_map; find_and_execute(some_map, 1, [](int key, int value){ std::cout << "key " << key << " found, value: " << value << std::endl; }, [](int key){ std::cout << "key " << key << " not found" << std::endl; }); 这样做的缺点是想出一个好名字,“find_and_execute”很尴尬,我想不出更好的名字...... map<string, string> m; 检查 key 是否存在,并返回出现次数(map 中为 0/1): int num = m.count("f"); if (num>0) { //found } else { // not found } 检查key是否存在,并返回迭代器: map<string,string>::iterator mi = m.find("f"); if(mi != m.end()) { //found //do something to mi. } else { // not found } 在你的问题中,由坏的operator<<过载引起的错误,因为p.first是map<string, string>,你无法打印出来。尝试这个: if(p.first != p.second) { cout << p.first->first << " " << p.first->second << endl; } 小心地将查找结果与地图“m”的结尾进行比较,因为所有答案都有 上面完成 地图::迭代器 i = m.find("f"); if (i == m.end()) { } else { } 您不应该尝试执行任何操作,例如如果迭代器 i 等于 m.end() 则打印键或值,否则会导致分段错误。 比较 std::map::find 和 std::map::count 的代码,我认为第一个可能会产生一些性能优势: const_iterator find(const key_type& _Keyval) const { // find an element in nonmutable sequence that matches _Keyval const_iterator _Where = lower_bound(_Keyval); // Here one looks only for lower bound return (_Where == end() || _DEBUG_LT_PRED(this->_Getcomp(), _Keyval, this->_Key(_Where._Mynode())) ? end() : _Where); } size_type count(const key_type& _Keyval) const { // count all elements that match _Keyval _Paircc _Ans = equal_range(_Keyval); // Here both lower and upper bounds are to be found, which is presumably slower. size_type _Num = 0; _Distance(_Ans.first, _Ans.second, _Num); return (_Num); } find() 和 contains() 都可以使用。根据文档。两种方法平均时间为常数,最坏情况下为线性时间。 我知道这个问题已经有一些很好的答案,但我认为我的解决方案值得分享。 它适用于 std::map 和 std::vector<std::pair<T, U>>,并且可从 C++11 开始使用。 template <typename ForwardIterator, typename Key> bool contains_key(ForwardIterator first, ForwardIterator last, Key const key) { using ValueType = typename std::iterator_traits<ForwardIterator>::value_type; auto search_result = std::find_if( first, last, [&key](ValueType const& item) { return item.first == key; } ); if (search_result == last) { return false; } else { return true; } } map <int , char>::iterator itr; for(itr = MyMap.begin() ; itr!= MyMap.end() ; itr++) { if (itr->second == 'c') { cout<<itr->first<<endl; } } 如果你想比较成对的地图,你可以使用这个方法: typedef map<double, double> TestMap; TestMap testMap; pair<map<double,double>::iterator,bool> controlMapValues; controlMapValues= testMap.insert(std::pair<double,double>(x,y)); if (controlMapValues.second == false ) { TestMap::iterator it; it = testMap.find(x); if (it->second == y) { cout<<"Given value is already exist in Map"<<endl; } } 这是一项有用的技术。


ASP.NET MVC 多选下拉列表

我使用以下代码让用户选择表单上的多个位置。 @Html.DropDownListFor(m => m.location_code, Model.location_type, new { @class = "form-control", @multiple = "mul...


数形成三角形的三元组

问题很简单;给定 n (3 <= n <= 10^5), count all triplets i, j, k (0 < i < j < k <= n) so that they can be side lengths of a non-degenerate triangle. Print the answer m...


不要在 Emacs 中显示*编译*缓冲区,直到进程因错误或警告而退出

我正在寻找一种方法,让由 M-x 编译、M-x 重新编译或某些保存时编译脚本触发的 Emacs 编译缓冲区仅在编译因错误或 w...而退出时出现。


如何使用映射字符串对象 firebase 检索复选框的数据

我使用以下方法在 firebase 中上传数据: HashMap m = new HashMap(); if(approved.isChecked()){ m.put("


预提交检查如何在本地失败但在 CI 服务器上通过?

我的开发机器上有一个干净的分支工作树。如果我运行 pre-commit run --all-files 我的格式化程序挂钩会失败,从而重新格式化一些文件。我的 CI 服务器 (Atlassian Bamboo) 也运行预


Pinia / TypeScript 从操作中访问 getter — 类型上不存在属性

我有一家商店。 导出 const useGameStore = DefineStore("游戏", { 状态:() => gameBaseState, 吸气剂:{ 发现标记(状态):标记[] { 返回 state.markers.filter((m) =...


这两种转换方式有什么区别?

我有以下代码(从浮点数转换为十六进制数): 浮点数小数 = 12.1; int num = (int) 小数; // <- (Method 1) int num2 = (*(int*) &decimal); // <- (M...


Apache Beam DirectRunner 与 FlinkRunner 示例

我使用beam yaml(python sdk)构建了最简单的管道,其中读取csv文件并应打印到日志。 使用默认 DirectRunner 运行时: python -m apache_beam.yaml.main --


Linux 内核稀疏 - 警告:转换为受限 __le64

构建 Linux 内核源代码的 /drivers/staging/vt6655 部分时: 使 M=drivers/staging/vt6655 C=2 稀疏抱怨 drivers/staging/vt6655/card.c:302:45:警告:转换为


SQL Server 上的查询过滤器 (ArcGIS Pro)

目前我正在尝试将 Oracle 数据库上的旧查询过滤器升级到 SQL 服务器。旧查询如下: select * from table.a a, table.b b WHERE sdo_relate(a.shape, b.shape, 'm...


如何修复“找不到 GLEW(缺少:GLEW_INCLUDE_DIR GLEW_LIBRARY)”

看来您正在使用 GCC 为 Linux 原生构建 Linux 上的 Cocos2dx:“cmake -G 'CodeBlocks - Unix Makefiles' -- OpenGL 包含目录:/usr/include CMake 错误位于 /usr/local/share/cmake-3.4/M...


K6 - 阈值已通过,但其值为零

我仅在本地运行 1 个 VU 的 K6 脚本。然而,“创建”阈值尽管通过了,但显示为零。我用其他方式写的,比如“http_req_duration{name:${}/cases,m...


Python程序中将罗马数字转换为整数时出错(我找到了解决方案,但显然我现在无法删除它)

def romanToInt(self, s: str) -> int: 数量 = 0 lst = ["I","V","X","L","C","D","M"] dict = {“我&quo...


构建 pygdal 时出错:未知的分发选项:“use_2to3_fixers”和“use_2to3_exclude_fixers”

解决方案如下: 在 Ubuntu 20.04 上构建 pygdal 时开始出现错误: # 命令 python3 -m pip install --no-cache-dir pygdal==3.0.4.* 产生以下输出 收集 pygda...


通过计算 R 中多个指定列的值来聚合数据集

我的数据集包含几列:第一列“性别”有 2 个值(M/F),第二列“组”表示品种组(40 个不同的值),每个


我可以让 argparse 在两个选项名称之后不重复参数指示吗?

当我为 argparse 指定一个具有短名称和长名称的参数时,例如: parser.add_argument("-m", "--min", dest="min_value", type=float, help="最小值...


Python SimpleHTTPServer 与 PHP

我使用了 python -m SimpleHTTPServer,但是 PHP 文件没有执行,而是只是被下载了。 我在一篇旧帖子中听说过 WPHP。但我不知道如何使用它。 我如何使用它?


在AGI文件中的MOH期间获取DTMF

我有 asterisk 13.21.0 并开发了一个基于 perl 的 agi。我正在尝试使用 agi 中的 EXEC() 函数执行带有“m”选项的 WaitExten 应用程序。 例如。 $AGI->exec("WaitExten",&...


Gurobi:不支持的操作数类型 -:'int' 和 'tupledict'

我有一个带有大M参数和辅助二进制变量w的约束: 对于客户中的我: 对于客户中的 j: 如果我!= j: mdl.addConstr(y[j] + z[j] <= y[i] + z[...


无法从 tmux 中的 `run-shell` 创建新会话

我有这个+x脚本 〜/ bin / tmux-test.sh: #!/usr/bin/bash tmux 新w 在我的 .tmux.conf 中: bind -n M-g run-shell `~/bin/tmux-test.sh` 有用... ...但是如果我将 tmux neww 更改为 tmux new (对于 cre...


usercustomize.py 自动运行但不存储变量和函数

我已按照本主题中的说明进行操作: 有没有办法让python启动时始终执行脚本? (类似 R 中的 site.profile) python3 -m site 的部分输出: USER_SITE:'/home/<


为什么我无法安装tensorflow?

我确定我使用的是3.6版本,并且我尝试了一切。 这是我尝试过的: py -m pip 安装张量流 错误:找不到满足张量流要求的版本(来自版本:...


如何处理自定义序列化器中属性的属性?

我有基于symfony5.4的应用程序。在这个应用程序中,我为客户提供了一个这样的课程: 类客户端 { #[Context([DateTimeNormalizer::FORMAT_KEY => 'Y-m-d'])] 公共 \DateTimeImmutable $


在 C# 中获取肽的所有 DNA 编码

我想获得肽的所有DNA编码:肽是氨基酸序列,即氨基酸M和氨基酸Q可以形成肽MQ或QM。 DNA编码意味着有一个DNA代码(称为...


© www.soinside.com 2019 - 2024. All rights reserved.