Visualforce: Can't access archived static resource - salesforce

I'm trying to access some static resource in my visualforce page. I have uploaded a zip file named pqGrid. It's structure is like so:
- pqgrid.min.js
- pggrid.min.css
- images/
--image1.png
--image2.png
Following the directions in the sf docs on [referencing a static resource1, I tried the following:
<apex:includeScript value="{!URLFOR($Resource.pqGrid, 'pqgrid.min.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.pqGrid, 'pqgrid.min.css')}"/>
Onloading the page, I get a 404:
GET
https://c.cs10.visual.force.com/resource/7975978979000/pqGrid/pqgrid.min.js
404 (Not Found)
GET https://c.cs10.visual.force.com/resource/7975978979000/pqGrid/pqgrid.min.css
I've even tried just referencing an image:
<apex:image url="{!URLFOR($Resource.pqGrid, 'images/cross.png')}"/>
and same 404:
GET
https://c.cs10.visual.force.com/resource/7975978979000/pqGrid/images/cross.png
404 (Not Found)
I've made sure that the resource cache control is public
What am I doing incorrectly?
EDIT
Tried putting all the files into another directory, so it is now pqGrid/stash/[*files]
When I get the 404 not found:
GET
https://c.cs10.visual.force.com/resource/1430434594000/pqGrid/stash/pqgrid.min.css
I tried playing with this url. Trying to navigate to just /stash/ throws a ERR_INVALID_RESPONSE error. Navigating to just /pqGrid/ let's me download the stuff. Trying to go directly to the file, /pqGrid/stash/file.js I just get a blank page.
So the zip is definitely on salesforce, but something is up with accessing it.
Thanks all!

This happens when we specify incorrect paths for our files would suggest to try below
<apex:includeScript value="{!URLFOR($Resource.pqGrid, 'pqgrid/pqgrid.min.js')}"/>
<apex:stylesheet value="{!URLFOR($Resource.pqGrid, 'pqgrid/pqgrid.min.css')}"/>
Sometimes forgetting slash also introduces issues
<apex:includeScript value="{!URLFOR($Resource.pqGrid, '/pqgrid.min.js')}"/>

Related

Spring static content(css) not served properly (spring boot)

I have a spring boot app and a controller that server static webpage(React build):
#Controller
#RequestMapping("/test")
public class HomeController {
#GetMapping("/")
public String index() {
return "index.html";
}
...
index.html is located at: ../resources/static/index.html
also in application.yml:
spring:
mvc:
static-path-pattern: /test/**
I am having two problems(problem 2 is the main issue):
I must call the following url with the trailing '/' at the end: http://localhost:8100/test/ I would like for http://localhost:8100/test to also map me to the view(index.html).
during the load of the page I am getting the following error:
the problem as you can see is that the url called is:
http://localhost:8100/static/css/main.6c417d20.chunk.css
and not
http://localhost:8100/test/static/css/main.6c417d20.chunk.css
(please note that the reason for the 'static' in the url is that there is a folder named: static below the resources/static folder so there is no issue with the 'static' in the url)
is it a server side problem or is it something I should fix in the react?
I searched for an answer but didn't find anything helpful.
any help would be highly appreciated,
Tnx
So the answer to my question lies in the following links:
how to build react to a non root path(homepage):
build react non root path
registering zuul client to the following path(that contains all resources):
Zuul configuration with resources
so I am leaving this here in case someone has the same issue(the answer in the second link is for vue.js and webpack,the first link explains how to change root address in react).
Answer 1 : #RequestMapping has a String[] value parameter, so can specify multiple values like this:
#RequestMapping(value={"", "/", "welcome"})
Answer 2 : You are expecting test in URL which is controller mapping not the project context path so it should not come in static resources urls.
see this answer for more clarity adding css and js in spring boot.

ceilometer --debug meter-list (pike version) error 404 not found

I could see the following result:
See this image please
What could the issue be? Which files should I make modifications in?
I tried changing /etc/ceilometer/ceilometer.conf
[keystone] and [service_credential] auth_uri and auth_url.However,when that did not work I changed it to what it was.
Endpoint is http://controller:8777
auth_uri is http://controller:5000
auth_url is http://controller:35357
Also, ceilometer alarm-list works fine but ceilometer meter-list gives HTTP 404 Not Found Error.

REACT PDF: Cannot use the packages to show static PDF file

I am trying to show a static pdf in React app. I have tried a lot of packages:
react-pdf
react-pdf-js
react-pdf-js-infinite
simple-react-pdf
pdfjs-dist
react-pdf-pages
They often say that we can use the URL, or pdf file for the props for the PDF component easily, but I cannot use either.
I had two main errors.
As I want to use myPDF for the props for the component, I write this:
import myPDF from 'path/to/pdf_file';
then, render_some_component pdf:{myPDF}
Here is the error:
ModuleParseError in
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type.
(Source code omitted for this binary file)
(When I comment that line, this kind of error disappears)
I used the file-loader in webpack config, I have tried many different ways but failed.
I use the pdf file directly for the props like this:
render_some_component pdf:{'path/to/pdf_file'}
In the Console:
Warning: Setting up fake worker.
11:23:55.962 pdf.worker.js:349 Warning: Ignoring invalid character "33" in hex string
11:23:55.963 pdf.worker.js:349 Warning: Ignoring invalid character "79" in hex string
...
There are a lot of 'Ignoring invalid character' like that and it always ends with:
localhost/:1 Uncaught (in promise) InvalidPDFException {name: "InvalidPDFException", message: "Invalid PDF structure"}
In the Network, Headers, I see:
Request URL:http://localhost:3000/myPdfFile.pdf
Request Method:GET
Status Code:200 OK
Remote Address:127.0.0.1:3000
but In the Network, Response, I see just the HTML layout.
I think the pdf file is loaded correctly but the package cannot recognize its PDF structure.
Except that two main errors, I had another error related to the Worker used in the packages but I don't know how to fix it:
Uncaught DOMException: Failed to construct 'Worker'
(This is something relates to Chrome as people say Chrome does not allow Worker in the local server)
Any help is highly appreciated as I am stuck in this in 4 days already.
Can you pleas clarify what you main task is?
If I understood it right you want to display a PDF file that already exists in a part of your application? You don't want to create a new PDF with JavaScript.
If you want to just show a PDF have you tried to use iframe?
Something like this:
<iframe
title="file"
style={{ width: '100%', height: '100%' }}
src={downloadURL}
/>
You ca use here also relative paths to the file from the location where your Component is or use full URLs to the file.

Copy static files from one Jekyll post to published site

I would like to copy any static file (image, PDF, etc.) found in a post folder inside _posts to the folder in which the HTML version of the post will be, inside _site.
Let's say I have this structure:
_posts/
2016/
06/
09-so-long-cloudflare/
2016-06-09-so-long-cloudflare-and-thanks-for-all-the-fissh.md
cloudflare-logo.png
performance-report-sample.pdf
My Jekyll settings for permalinks are:
# Permalinks
permalink: /:year/:month/:day/:title/
I would like to generate the site like this:
2016/
06/
09/
so-long-cloudflare-and-thanks-for-all-the-fissh/
index.html
cloudflare-logo.png
performance-report-sample.pdf
I've found this plugin that should do this, but I can't make it work. I get this error:
jekyll 3.1.6 | Error: undefined method `name' for #<Jekyll::Document:0x007fb7a0892b50>
Any idea?
Thanks!
Well, despite having no Ruby knowledge, I managed to build a plugin out of this old Gist! \o/
https://nhoizey.github.io/jekyll_post_files/
I hope this will help people with the same needs.

CakePHP 2.1 new install Missing Controller Error

I am completely new to CakePHP and installed 2.1. I am getting this error:
Missing Controller
Error: Index.phpController could not be found.
Error: Create the class Index.phpController below in file: app\Controller\Index.phpController.php
<?php
class Index.phpController extends AppController {
}
Notice: If you want to customize this error message, create app\View\Errors\missing_controller.ctp
Stack Trace
APP\webroot\index.php line 96 → Dispatcher->dispatch(CakeRequest, CakeResponse)
ROOT\index.php line 40 → require(string)
I followed their guide at http://book.cakephp.org/2.0/en/installation/advanced-installation.html and tried everything it stated:
I enabled mod_rewrites (they were already enabled from something else)
I have all the .htaccess files in the directories
I have cake installed under my document root so I access it at localhost/cakephp/index.php
I do not know where to proceed from here. Thanks for any help you can give me.
Update: I just re-read your question and realized you're loading http://localhost/cakephp/index.php. Don't do that. Since you appended "index.php", it is trying to load a controller called "index.php" and the action "index" for that controller. Resulting mapped path to the "index.php controller" is app\Controller\Index.phpController.php.
Since you have the rewrites enabled, browse to http://localhost/cakephp without appending any filename.
Original answer:
Assuming you're using Apache, double-check the .htaccess in your /app/webroot directory. It should include the following:
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
Based on your error, it doesn't look like it's properly appending the path after your index.php file.
If you are using cakephp 2.0 or greater than rename the controller file name as the class name.
ie TaskController.php
class TasksController extends AppController {
--Your code inside class
}
I hope this will help you
the easiest solution is to stick to the "live environment" as close as possible.
this means using vhosts to use a "domain" and correctly root down to your webroot dir:
http://www.dereuromark.de/2011/05/29/working-with-domains-locally/
this leaves almost no room for error and also helps with other potential problems like "absolutely linked asset files" etc

Resources