iOS9中的Universal Links使用Handoff机制查看应用程序中的链接而不是浏览器:每当点击Universal Link时,iOS会激活相应的应用程序,并-application:continueUserActivity:restorationHandler使用包含Universal Link URL的用户活动进行调用(请参阅Apple环球指南)链接).
我想手动触发这个机制,即创建一个NSUserActivity具有webpageURL属性的实例并将其分派给当前应用程序处理-application:continueUserActivity:restorationHandler.有没有办法实现这个目标?
目前我只是-application:continueUserActivity:restorationHandler直接打电话,但这感觉不对,我想以更恰当的方式实施它.
我在 Rails 4 项目中使用carrierwave,文件存储用于开发和测试,雾存储(用于存储在Amazon S3上)用于生产。
我想用这样的路径保存我的文件:
/model_class_name/part_of_hash/another_part_of_hash/hash-model_id.file_extension
(例如:/images/12/34/1234567-89.png其中 1234567 是文件内容的 SHA1 哈希值,89 是数据库中关联图像模型的 id)。
到目前为止我尝试过的是:
class MyUploader < CarrierWave::Uploader::Base
def store_dir
"#{model.class.name.underscore}/#{sha1_for(file)[0..1]}/#{sha1_for(file)[2..3]}"
end
def filename
"#{sha1_for(file)}-#{model.id}.#{file.extension}" if original_file
end
private
def sha1_for file
Digest::SHA1.hexdigest file.read
end
end
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为:
model.idfilename被调用时不可用filestore_dir被调用时并不总是可用所以,来到我的问题:
filename?这个链接说不应该这样做;有没有办法解决它?store_dir?我没有找到这方面的文档,但到目前为止我的经验说“不”(见上文)。