0

我正在使用 Appcelerator 云服务将图片上传到云端,并希望以各种尺寸取回它。上传工作正常,但我没有取回照片。我收到了urlsJSON 响应:

这是我的代码:

    Cloud.Photos.show({
        photo_id: pid
    }, function (e) {
        if (e.success) {
            var photo = e.photos[0];
            waitDialog.hide();
            alert('Success:\n' +
                'id: ' + photo.id + '\n' +
                'filename: ' + photo.filename + '\n' +
                'updated_at: ' + photo.updated_at + '\n' +
                'urls: ' + photo.urls);

                alert(photo.urls.square);
                var image2 = photo.urls.square.toImage();

                var squareImage = Ti.UI.createImageView({
                    top: "10dp",
                    left: "10dp",
                    image: image2,
                    height: Titanium.UI.SIZE,
                    width: Titanium.UI.SIZE
                });

                $.index.add(squareImage);

        } else {
            alert('Error:\n' +
                ((e.error && e.message) || JSON.stringify(e)));
        }
    });

我收到这样的 JSON 响应(这不是原始的,因为我正在设备中测试它)

{
  "meta": {
    "status":"ok",
    "code":200,
    "method_name":"showPhoto"
  },
  "response": {
    "photos": [
      {
        "id":"4d51d4186f70952d4c000006",
        "filename":"photo.jpg",
        "size":584344,
        "collection_name":"default",
        "md5":"589b8ad43ed20bf8e622d719642bc939",
        "created_at":"2011-02-08T23:39:04+0000",
        "updated_at":"2011-02-08T23:39:08+0000",
        "processed":true,
        "content_type":"image/jpeg",
        "urls": {
          "square":"http://storage.appcelerator.com/c3e1d292cb79ba7b9783d6cd45344719/photos/4d51d4186f70952d4c000006/photo_square.jpg",
          "thumb":"http://storage.appcelerator.com/c3e1d292cb79ba7b9783d6cd45344719/photos/4d51d4186f70952d4c000006/photo_thumb.jpg",
          "small":"http://storage.appcelerator.com/c3e1d292cb79ba7b9783d6cd45344719/photos/4d51d4186f70952d4c000006/photo_small.jpg",
          "medium_500":"http://storage.appcelerator.com/c3e1d292cb79ba7b9783d6cd45344719/photos/4d51d4186f70952d4c000006/photo_medium_500.jpg",
          "medium_640":"http://storage.appcelerator.com/c3e1d292cb79ba7b9783d6cd45344719/photos/4d51d4186f70952d4c000006/photo_medium_640.jpg",
          "large":"http://storage.appcelerator.com/c3e1d292cb79ba7b9783d6cd45344719/photos/4d51d4186f70952d4c000006/photo_large.jpg",
          "original":"http://storage.appcelerator.com/c3e1d292cb79ba7b9783d6cd45344719/photos/4d51d4186f70952d4c000006/photo_original.jpg"
        }
      }
    ]
  } 
}

我想从urls.

我需要解析它还是我需要做的其他事情?谁能告诉我该怎么做?

谢谢 :)

4

1 回答 1

0

像这样分配照片

squareImage.image =photo.urls.square;
于 2013-07-26T13:19:45.823 回答