triggerIO从图库上传图片

时间:2013-05-03 19:31:14

标签: trigger.io

我无法使用coffeescript

通过图库通过触发器上传图片

相关代码:

主要剧本:

CameraHelper.fileUpload (file) =>
    @file = file
    forge.file.URL file, (url) =>
        @fileURL = url
        @$("#uploadImg").addClass("fadeIn").css("background-image", "url(#{url})")
    , (content) ->
        error "Error finding Image"
    , ->
        debug "Upload Cancelled"

相机助手:

fileUpload: (success, err) ->
    forge.file.getImage
        saveLocation: "file"
    , (file) ->
            debug "Successfully uploaded img"
            success?(file)
    , (content) ->
            error "Error in uploading img", content
            err?()

相关调试信息:

选择并拍摄相机时:

[FORGE] '{"uri":"/var/mobile/Applications/1BC9C0D7-5830-402E-913A-C39764B41F26/Library/Application Support/Forge/389301995108.jpg","name":"Image","type":"image"}'
all.js:2[FORGE] 'Successfully uploaded img'

选择图库图像时:

assets-library://asset/asset.JPG?id=A3907A31-A8F9-4763-AEF2-67BA84F8E245&ext=JPG 
Failed to load resource: unsupported URL

1 个答案:

答案 0 :(得分:1)

解决。

必须添加forge.file.URL函数才能正确访问图片的网址

more details here