在 Google Analytics API 文档中,您可以查看 Python 中的“服务应用程序”和“已安装应用程序”的 API。这两者有什么区别?“Web 应用程序”的 Python 选项不可用...这是为什么?
非常感谢您的帮助!
google-analytics google-analytics-api google-analytics-firebase
我正在尝试解决上传非带有操作文本的图像的文件的问题,并使它们对查看帖子的用户有用。例如,如果在创建某些内容时上传了 PDF,用户应该能够下载。
\n\n现在我的图像上传和显示都很好,但如果我上传了 PDF,它会显示文件名和大小:
\n\nBla.pdf 635 KB。看起来这是不可点击的:
\n\n\n\n下面的 html 是:
\n\n<action-text-attachment sgid=\xe2\x80\x9dBAh7CEkiCGdpZAY6BkVUSSI4Z2lkOi8vdGFhYWxrLWVkZ2UvQWN0aXZlU3RvcmFnZTo6QmxvYi82OD9leHBpcmVzX2luBjsAVEkiDHB1cnBvc2UGOwBUSSIPYXR0YWNoYWJsZQY7AFRJIg9leHBpcmVzX2F0BjsAVDA= \xe2\x80\x94 9fc1638e6a6bca562cbff92f1627dfcf9e74f198" content-type=\xe2\x80\x9dapplication/pdf\xe2\x80\x9d url="http://localhost:3000/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBTUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--5da8c8c82a642f3ed3f0c158a2560a7a41b974c7/Bla.pdf" filename=\xe2\x80\x9dBla.pdf\xe2\x80\x9d filesize=\xe2\x80\x9d649993"><figure class=\xe2\x80\x9dattachment attachment \xe2\x80\x94 file attachment \xe2\x80\x94 pdf\xe2\x80\x9d>\n<figcaption class=\xe2\x80\x9dattachment__caption\xe2\x80\x9d>\n<span class=\xe2\x80\x9dattachment__name\xe2\x80\x9d>Bla.pdf</span>\n<span class=\xe2\x80\x9dattachment__size\xe2\x80\x9d>635 KB</span>\n</figcaption>\n</figure></action-text-attachment>\nRun Code Online (Sandbox Code Playgroud)\n\n有什么想法可以让我下载这个吗?
\n\n谢谢
\n在我的应用程序中,管理员用户可以建议和编辑其他用户的个人资料。我希望管理员用户能够为非管理员用户建议一个(新的)头像。目前我的用户(用户=spkr在我的应用程序中)模型具有:
has_one_attached :image
has_one_attached :edited_image
Run Code Online (Sandbox Code Playgroud)
哪里image是用户选择的头像图片,哪里edited_image是管理员用户建议的头像图片。
当使用管理“更新”表单时,edited_image设置
if spkr_params[:edited_image].present?
@spkr.edited_image = spkr_params[:edited_image]
end
Run Code Online (Sandbox Code Playgroud)
这成功地将附件设置为edited_image.
当管理员用户提交编辑时,非管理员用户会收到一封确认电子邮件。单击时,我希望image非管理员用户的 进行更新。
...
if @spkr.edited_image.present?
@spkr.image.purge
@spkr.image = @spkr.edited_image
end
@spkr.save!
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误@spkr.save!:
Could not find or build blob: expected attachable, got #<ActiveStorage::Attached::One:0x00007fdcc44fa440 @name="edited_image", @record=#<Spkr id: 154... >>
Run Code Online (Sandbox Code Playgroud)
这是edited_image来自@spkr:
@spkr.edited_image
=> #<ActiveStorage::Attached::One:0x00007fdcc44fa440 @name="edited_image", @record=#<Spkr id: 154...>>
Run Code Online (Sandbox Code Playgroud)
我的感觉是 @spkr.edited_image 不是 @spkr.edited_image 的“可附加部分”,但我不确定如何解决这个问题。
感谢您的任何帮助。
我正在尝试在 Rails 6 应用程序中使用 ActionText。我能够创建 blob,但是:
\n\n
\n 2. 我的“图像附件”在撰写邮件时看起来有点奇怪...但这也许是正常的?
我按照https://edgeguides.rubyonrails.org/action_text_overview.html上的说明进行操作。
\n\n我的 application.js 文件如下所示:
\n\n// This file is automatically compiled by Webpack, along with any other files\n// present in this directory. You\'re encouraged to place your actual application logic in\n// a relevant structure within app/javascript and only use these pack files to reference\n// that code so it\'ll be compiled.\n\nrequire("@rails/ujs").start()\nrequire("turbolinks").start()\nrequire("@rails/activestorage").start()\nrequire("channels")\n\n\n// Uncomment to copy all static images under …Run Code Online (Sandbox Code Playgroud)