小编Cra*_*ath的帖子

WP Rest API上传图片

我正在尝试通过Wordpress REST api v2上传图像.到目前为止,我所做的只是在wordpress媒体库中创建空条目.意思是他们有图像名称,但没有实际图像.

POST请求:

http://localhost/wordpress/wp-json/wp/v2/media

Authorization: Basic d29yZHByZXNzOndvcmRwcmVzcw==
Content-Type: application/json
Content-Disposition: attachment;filename=map2.jpg

{
  "source_url" : "file:///C:/Users/x/Desktop/map2.jpg"
}
Run Code Online (Sandbox Code Playgroud)

响应:

{
  "id": 127,
  "date": "2016-05-25T08:43:30",
  "date_gmt": "2016-05-25T08:43:30",
  "guid": {
    "rendered": "http://localhost/wordpress/wp-content/uploads/2016/05/map2-3.jpg",
    "raw": "http://localhost/wordpress/wp-content/uploads/2016/05/map2-3.jpg"
  },
  "modified": "2016-05-25T08:43:30",
  "modified_gmt": "2016-05-25T08:43:30",
  "password": "",
  "slug": "map2-3",
  "status": "inherit",
  "type": "attachment",
  "link": "http://localhost/wordpress/map2-3/",
  "title": {
    "raw": "map2-3",
    "rendered": "map2-3"
  },
  "author": 1,
  "comment_status": "open",
  "ping_status": "closed",
  "alt_text": "",
  "caption": "",
  "description": "",
  "media_type": "image",
  "mime_type": "image/jpeg",
  "media_details": {},
  "post": null,
  "source_url": "http://localhost/wordpress/wp-content/uploads/2016/05/map2-3.jpg",
  "_links": {
    "self": [ …
Run Code Online (Sandbox Code Playgroud)

wordpress

16
推荐指数
3
解决办法
2万
查看次数

Java spring控制器未被映射

我有一个spring web应用程序,它有很少的控制器.我的问题是,当尝试将.war重新部署到tomcat(或者只是重新启动应用程序)时,控制器没有从第一次尝试映射.我必须重新部署应用程序或重新启动,直到它们最终映射...我不知道为什么会发生这种情况.

我的一个控制器:

@RestController
@RequestMapping("kt")
public class KTIntegrationController {

    @Autowired
    KtImportService importService;

    @ExceptionHandler(ItemNotFoundException.class)
    @ResponseStatus(value= HttpStatus.NOT_FOUND)
    public RestError handleNotFoundException(ItemNotFoundException e) {
        return new RestError(404, "NOT FOUND", e.getMessage());
    }

    @RequestMapping(value="import/to-db", method=RequestMethod.POST)
    public RestResponse<List<String>> loadToDB(@RequestParam("initiator") String initiator,
                            @RequestParam("process") String pid,
                            @RequestParam("category") String institution) throws KtImportException {
        return new RestResponse<List<String>>(importService.loadToDB(initiator,pid,institution));
    }

}
Run Code Online (Sandbox Code Playgroud)

Tomcat日志(未映射控制器时):

...
...
[12:47:40.887] INFO  o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@bf5b3f: startup date [Thu Aug 27 12:47:23 EEST 2015]; root of context hierarchy
[12:47:41.107] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, …
Run Code Online (Sandbox Code Playgroud)

java spring tomcat spring-mvc

5
推荐指数
1
解决办法
1万
查看次数

FtpClient 检索文件流 [挂起]

我有一个本地 FTP 服务器(使用 FileZilla 服务器创建),并且很少有 XLS 文件。我需要将文件输入流返回到我的 Java 应用程序,以便我可以解析数据等。

为此,我尝试使用 FTPClient,但出于某种原因,在尝试从文件(大于 40KB 或)返回输入流时,FTPClient.retrieveFileStream() 挂起。

我知道有与此类似的问题,我已经阅读了所有内容,至少我能找到的所有内容都已阅读,但没有任何帮助。这真的很烦人,如果可能的话,我想要一些帮助。

相关代码部分:

public FTPwrapper(){

    ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
    Properties props = (Properties) context.getBean("ftp_props");

    this.FTPhost = props.getProperty("host");
    this.FTPuser = props.getProperty("user");
    this.FTPpass = props.getProperty("pass");
    this.FTPport = Integer.parseInt(props.getProperty("port"));
    this.filesPath = props.getProperty("filesPath");
    //start ftp connection
    try {
        client.connect(this.FTPhost, this.FTPport);
        client.login(this.FTPuser, this.FTPpass);
        client.setBufferSize(1024 * 1024);
        client.enterLocalPassiveMode();
        client.setFileType(FTP.BINARY_FILE_TYPE);
    } catch (IOException e) {
       e.printStackTrace();
    } 
}
Run Code Online (Sandbox Code Playgroud)
public InputStream returnFileStream(String FileName){

    InputStream inputstream = null;

    try {
        String remoteFile = this.filesPath+FileName;
        inputstream …
Run Code Online (Sandbox Code Playgroud)

java ftp inputstream

2
推荐指数
1
解决办法
7660
查看次数

标签 统计

java ×2

ftp ×1

inputstream ×1

spring ×1

spring-mvc ×1

tomcat ×1

wordpress ×1