在Google云端硬盘中列出文件时如何排除已删除的文件(How to exclude trashed files when listing files in google drive)
我想使用谷歌驱动器api v2列出谷歌驱动器中的所有文件。 但我想排除列表中的垃圾文件
所以我尝试了
GET https://www.googleapis.com/drive/v2/files?trashed=false
正如在api文档中所建议的那样但是我仍然在垃圾文件夹中找到文件,我是否错过了某些内容? 或者它是驱动API中的一个已知错误?
I want to list all the files in google drive using google drive api v2 . But I want to exclude files in trash in the list
So I tried
GET https://www.googleapis.com/drive/v2/files?trashed=false
as suggested in the api documentation But still I get files in the trash folder ,Am I missing something ? Or is it a known bug in drive api?
原文:https://stackoverflow.com/questions/29892495
最满意答案
我使用了另一种方法 - 弹簧
RetryTemplate
- 并找到了一个RetryTemplate
解决方案。 这是我的主要应用程序类:@SpringBootApplication public class RetryApplication { public static void main(String[] args) throws Exception { SpringApplication.run(RetryApplication.class, args); } }
包含要重试的方法的类:
public class MyRetry { @Autowired private RetryTemplate retryTemplate; public void myMethod() throws Exception { retryTemplate.execute( new RetryCallback<Void, Exception>() { @Override public Void doWithRetry(RetryContext context) throws Exception { System.out.println("Attempt..."); throw new Exception(); } }, new RecoveryCallback<Void>() { @Override public Void recover(RetryContext context){ System.out.println("Recovering..."); return null; } } ); } }
配置类:
@EnableRetry @Configuration public class MyConfiguration { @Bean public MyRetry myBean() throws Exception { return new MyRetry(); } @Bean public RetryTemplate retryTemplate() { SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(); retryPolicy.setMaxAttempts(5); FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy(); backOffPolicy.setBackOffPeriod(1500); // 1.5 seconds RetryTemplate template = new RetryTemplate(); template.setRetryPolicy(retryPolicy); template.setBackOffPolicy(backOffPolicy); return template; } }
和一个utils类:
@Component public class MyUtility implements ApplicationContextAware { @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { MyRetry myRetry = applicationContext.getBean(MyRetry.class); try { myRetry.withTemplate(); } catch (Exception e) { e.printStackTrace(); } } }
此代码尝试调用
myMethod()
5次,然后恢复。 这是非常微不足道的,但有时微不足道的事情是最棘手的。 一些来源: 关于重试的春季文档和一个有用的教程 。I used a different approach - the spring
RetryTemplate
- and found a working solution. Here's my main application class:@SpringBootApplication public class RetryApplication { public static void main(String[] args) throws Exception { SpringApplication.run(RetryApplication.class, args); } }
The class that contains the method to retry:
public class MyRetry { @Autowired private RetryTemplate retryTemplate; public void myMethod() throws Exception { retryTemplate.execute( new RetryCallback<Void, Exception>() { @Override public Void doWithRetry(RetryContext context) throws Exception { System.out.println("Attempt..."); throw new Exception(); } }, new RecoveryCallback<Void>() { @Override public Void recover(RetryContext context){ System.out.println("Recovering..."); return null; } } ); } }
The configuration class:
@EnableRetry @Configuration public class MyConfiguration { @Bean public MyRetry myBean() throws Exception { return new MyRetry(); } @Bean public RetryTemplate retryTemplate() { SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(); retryPolicy.setMaxAttempts(5); FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy(); backOffPolicy.setBackOffPeriod(1500); // 1.5 seconds RetryTemplate template = new RetryTemplate(); template.setRetryPolicy(retryPolicy); template.setBackOffPolicy(backOffPolicy); return template; } }
And a utils class:
@Component public class MyUtility implements ApplicationContextAware { @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { MyRetry myRetry = applicationContext.getBean(MyRetry.class); try { myRetry.withTemplate(); } catch (Exception e) { e.printStackTrace(); } } }
This code tries to call
myMethod()
5 times, then recovers. It's really trivial but sometimes trivial things are the trickiest. Some sources: spring documentation on retry and a useful tutorial.
相关问答
更多-
是不是有一款什么手机软件,可以很自然的拉长腿部?不是美图秀秀,有知道的不?[2022-10-20]
spring -
春天的英语怎么读?[2022-05-21]
spring -
你看到的问题是由于你如何调用你的getInfo()方法。 在第一个例子中,你是从同一个spring管理bean中调用getInfo() 。 在第二个示例中,您将从不同的弹簧托管bean调用getInfo() 。 这种区别很微妙,但非常重要,很可能是导致问题的原因。 当你使用@Retryable注解时,Spring正在你的原始bean周围创建一个代理,以便他们可以在特殊情况下进行特殊处理。 在这个特定情况下,Spring应用一个Advice,它将把一个调用委托给你的实际方法,捕获它可能抛出的RuntimeEx ...
-
我使用了另一种方法 - 弹簧RetryTemplate - 并找到了一个RetryTemplate解决方案。 这是我的主要应用程序类: @SpringBootApplication public class RetryApplication { public static void main(String[] args) throws Exception { SpringApplication.run(RetryApplication.class, args); } } 包 ...
-
Spring-Retry:创建类似于@Retryable的自定义注释(Spring-Retry: Create custom annotation similar to @Retryable)[2022-03-31]
这有几种方法: 使用spring-retry项目并将其集成到您的应用程序中。 但正如你所说,这不是你想要的。 这个框架提供的不仅仅是对异常的简单重试,而且比第一眼看起来要复杂得多。 使用AspectJ(Aspect Oriented Programming)模型和库 创建一个自定义注释,在运行这些方法之前检查你的类,看看它是否用@CustomRetryable注释,然后运行重试方法。 然而,这不是很简单,需要与你的课程正确结合。 哪一个取决于你的应用程序是如何设计的 如果你想保持它尽可能简单:创建一个助手类 ... -
将重试拦截器配置为bean并在interceptor属性中指定它; 有一个RetryInterceptorBuilder来帮助组装bean。 您可以将reoverer添加到拦截器中,该拦截器在重试耗尽后调用。 Configure a retry interceptor as a bean and specify it in the interceptor property; there's a RetryInterceptorBuilder to help with assembling the bean. ...
-
目前还不可能; 要在属性中连接,必须更改注释以获取字符串值,并且注释bean后处理器必须解析占位符和/或SpEL表达式。 有关替代方案,请参阅此答案 ,但目前无法通过注释完成。 编辑不使用注释@Retryable来使用org.springframework.amqp.rabbit.config.RetryInterceptorBuilder的目的。 其目的是与SimpleRabbitListenerContainerFactory类的建议链一起使用。 请参阅参考文档接收消息和SimpleMessageListenerContainer#invokeListener签名: @Override protected void invokeListener(Channel channel, M ...您的应用程序必须由Spring管理,您不能只使用new ... Parentservice p = new SpringRetryWithHystrixService(); 这是一个Spring Boot应用程序...... @SpringBootApplication @EnableRetry public class So40308025Application { public static void main(String[] args) throws Exception { ...
Spring Cloud - 在RestTemplate中重试工作?(Spring Cloud - Getting Retry Working In RestTemplate?)[2023-06-03]
回答我自己的问题: 在我进入细节之前,一个警示故事: Eureka的自我保护模式让我在测试本地机器上的故障转移时将我的兔子洞弄得一团糟。 我建议您在进行测试时关闭自我保护模式。 因为我以常规速率丢弃节点然后重新启动(使用随机值使用不同的实例ID),我绊倒了Eureka的自我保护模式。 我在Eureka结束了许多指向相同机器,同一端口的实例。 故障转移实际上正在工作,但选择的下一个节点恰好是另一个死实例。 一开始很混乱! 我能够使用RibbonClientHttpRequestFactory的修改版本进行故障 ...相关文章
更多- elasticsearch too many open files
- Hadoop Java程序-files功能测试
- flume写入Hadoop hdfs报错 Too many open files
- google weather 图标
- Google TTS(文字转语音)api 2
- Guava学习笔记:Google Guava 类库简介
- Google Gson库的主要操作类Gson详解
- 最简单下拉刷新,Google最新(可刷新任何控件)
- [google面试CTCI] 1-5.替换字符串中特定字符
- 十分钟了解分布式计算:Google Dataflow
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)