使用 SharePoint 作为一种使用 Spring Boot 的 CMS

问题描述

我正在使用 Spring Boot 在 SharePoint 中为我的应用程序存储文件(基本上是尽可能多的格式 - 但考虑图像、文档),该应用程序部署在 SAP 的 Cloud Foundry 中。我几乎遵循了 this 帖子的答案中提到的步骤(并从那里复制了所有四个文件),我得到了一个 github repo,它几​​乎实现了同样的事情。我已经关注了他们,但有些东西对我不起作用。 (请参阅 StackOverflow 链接以进一步参考我正在谈论的内容)

SharePointServiceCached.java 中方法调用的顺序是 parseExecutionDateTime() -> receiveSecurityToken() -> getSignInCookies(securityToken) -> getFormDigestValue(cookies) 我收到了安全令牌(正如我从日志中检查的那样),但这是我收到的错误消息:

Document upload failed!org.springframework.web.client.HttpClientErrorException$Forbidden: 403 Forbidden: [403 FORBIDDEN]

我为此尝试过的事情:

  1. 向请求添加了 SSL 部分(请参阅列表末尾的代码),这似乎只会让情况变得更糟。
  2. 向标头添加了用户代理,这没有任何区别。
  3. 将端点域从 https://protected1.sharepoint.com/sites/protected2 更改为 https://protected1.sharepoint.com/,这又以某种方式使情况变得更糟。 (很明显,protected1 和protected2 是改名了)
  4. 让我自己(我传递其凭据的人)拥有所有权限。
  5. 我检查了日志,凭据正确传递。
    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder) 
    {
        CloseableHttpClient httpClient = HttpClients.custom().setSSLHostnameVerifier(new NoopHostnameVerifier())
                .build();
        HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
        requestFactory.setHttpClient(httpClient);
        RestTemplate rest = new RestTemplate(requestFactory);
        builder.configure(rest);
        return builder.build();
    }

此外,以前我使用 CMS 来处理相同的事情,它返回与上传文件关联的文档 ID。我在 SharePoint 中启用了文档 ID 选项,并希望以类似方式使用它,即上传文件 -> 获取文档 ID 并存储它 -> 在需要时使用该文档 ID 获取文件。我该怎么做?

提前致谢。

解决方法

明白了。我只需要发送我想要存储文件的路径。 while(entity = readdir(dir)) { puts(entity->d_name); } closedir(dir);

我现在正在随机生成 documentID。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...