簡體   English   中英

如何從ftp加載圖像並用Picasso庫處理它?

[英]How do you load an image from ftp and handling it with picasso library?

我想從我的ftp服務器上加載圖像,並用picasso庫顯示它。
可能嗎 ?
這是我的代碼,但是.load()不接受InputStream 有什么建議么?

try {

          FTPClient mFTPClient = new FTPClient();
          mFTPClient.connect("ftp.server.com");      
          mFTPClient.login("user","pass");
          mFTPClient.enterLocalPassiveMode();
          mFTPClient.changeWorkingDirectory("/public_ftp/");
          inStream = mFTPClient.retrieveFileStream("18.jpg");
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println( "Error communicating with FTP server." );
        }
         Picasso.with(this)
        .load(inStream)
        .placeholder(R.drawable.local_wallpaper) 
        .resize(200, 200)
        .centerInside()
        .into(mc, new com.squareup.picasso.Callback() {
                            @Override
                            public void onSuccess() {
                                Log.v("", "success");

                            }

                            @Override
                            public void onError() {
                                Log.v("", "Error");
                            }
                        });

正如達米安所說, picasso似乎不可能做到這一點。

您可以嘗試以下一些建議,

  1. 使用其他一些工具下載ftp映像,然后從內存中加載圖片。 但這會破壞picasso一個非常重要的功能-圖像緩存。 如果需要,您必須自己編寫代碼。
  2. 在服務器中創建一個模塊,以獲取ftp映像並將其轉儲為使用http協議的常規映像。
  3. Dnkutso 在此建議有關使用自定義RequestHandler 但我無法告訴您更多有關它的信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM