Como mencionado acima, este componente funcionará apenas em desktop. Há muito pouco benefício em mostrar as pré-visualizações no mobile, já que tudo ficará tão pequeno e muito difícil de ler.
Este componente usa a implementação nativa do navegador para renderizar os PDFs, então os resultados parecerão diferentes em diferentes navegadores.
Além disso, note que o upload de PDFs não é permitido por padrão no Discourse. Se você quiser permitir que seus usuários façam upload de arquivos PDF, precisará adicionar essa extensão às authorized_extensions se quiser que todos os seus usuários possam fazer upload de PDFs, ou às authorized_extensions_for_staff se quiser limitar isso a membros da equipe.
Access to fetch at 'https://travelmassive-discourse-cdn.s3.dualstack.us-west-1.amazonaws.com/original/2X/b/b578f6364592121964e6a2fd4969e5c1222bd909.pdf' (redirected from 'https://lounge.travelmassive.com/uploads/short-url/pTnA3r043WfhDK8HSdPQrtNn8Lf.pdf') from origin 'https://lounge.travelmassive.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Update
I was able to fix this by adding the following CORS policy in my S3 bucket configuration.
It’s necessary to add, that if you see this text in the error message from origin 'https://lounge.travelmassive.com' has been where your domain is without slash / at the end, then in the CORS configuration you should also add your domain without slash at the end like this: https://mydiscourse.url
I noticed that your uploads are on AWS so, the issue is probably CORS related (the component is not active on your site for me to confirm). See the post below yours.
thanks for sharing that!
Please note that this issue will only affect self-hosters that have set up something like S3. Self-hosters that are not using S3 will not run into this issue. Customers hosted by CDCK will also not need to worry about that since they already have that set up.
That said, CORS configuration is a bit outside of the scope of this topic. If your uploads bucket does not allow your own domain access, then that needs to be fixed regardless since there might be some other issues caused by that.
I’m a little bit unsure what happened here. Both cases seem to be working for me everytime I try. We can just chalk it up to a transitory network issue but please let me know if you see it again
I pushed a tiny update to this component that should improve the loading perception, there’s now a theme-color based placeholder instead of the default browser Iframe styles. It only shows up while the file is loading so 99% of the time, you won’t even notice it.
Would it be possible to make PDF Preview suppressable by prepending a space before the upload link, like with oneboxing? Sometimes you want a list of documents and not previews. Sometimes you want a preview.
I’m on Safari on MacOS Catalina, and I don’t have anything disabling in-browser PDF display—for instance, http://www.orimi.com/pdf-test.pdf displays fine. But I’m still getting the “Blocked Plug-in” window/message when I view the preview in theme-creator.
Site-specific settings in Safari prefs aren’t any different than other websites.
Still not working for me on Safari in MacOS Big Sur. No special settings to blog plugins, and other PDFs display in the browser.
Safari Web Inspector has the following complaints when loading the preview page in theme-creator: Unrecognized Content-Security-Policy directive 'worker-src'. Refused to load blob:https://theme-creator.discourse.org/7b9b62c7-e782-4080-a521-04e3b06aa142 because it does not appear in the object-src directive of the Content Security Policy.
meus links nas mensagens estão no formato domain/secure-media-uploads/original/...
mas no console/rede consigo ver que os downloads reais vêm do bucket
Você vê a credencial amz?
Se não, talvez isso ajude?
Também me lembro de que algo estranho acontecia quando tentei mover uma postagem de categorias (ou era uma cópia/cola?). No final, funcionou quando reenviei o arquivo.
Então estou sem ideias — especialmente sobre o motivo de funcionar em dois fóruns que eu administro e não no outro — sendo o S3 a única diferença. E que você consegue fazer funcionar com o S3. Estou realmente confuso.
Pode ser um conflito com outro componente ou tema. Está funcionando como esperado para mim. Comece desativando outros componentes e tente usar o tema padrão, se o seu for diferente. O mesmo vale para plugins.
Ok — fiz progresso. Desativar os uploads para o S3 resolve o problema para novos uploads. Mas fico com uma bagunça entre S3 e local se seguir por esse caminho!
Pode ser que eu não esteja usando o tal do CDN (CloudFront), que gera os erros irritantes na página de administração. Vou tentar configurá-lo e ver se funciona.
Estou procurando um plugin que permita abrir o PDF em uma nova aba.
O comportamento atual do meu Discourse é permitir apenas o download.
Seria possível fazer isso com um tema semelhante?