Serving local images with Play 2 to be displayed inline - scala

Earlier I asked how to serve a local image here: Serving local images with Play 2 / Scala
This works well, except that the image is forced to download by the browser, instead of being displayed in the browser.
I have added "inline = true" argument to OK.sendFile, as described here: http://www.playframework.com/documentation/2.2.x/ScalaStream , but that doesn't seem to work, the image is still being downloaded. It seems that Content Type is not getting recognized? Play documentation says it should automatically set it using the file extension, so not sure what's going. Help?
EDIT: Response header example:
HTTP/1.1 200 OK
Content-Length:2694220
Content-Type: application/octet-stream

Looking through Play's code, I realized I could simply add .withHeaders onto sendFile:
Ok.sendFile(content = new java.io.File("filepath"), inline = true).withHeaders(CONTENT_TYPE -> "image/jpeg")
This solved the problem! Thanks #biesior for the pointer.

Related

Cannot embed image/gif to GitHub page

I'm trying to embed a GIF in a GitHub Pages page and tried every single way I found online can work. Here's my link:
https://github.com/jellyfishrui/Interactive-Programming-in-Python-Rice-University/blob/master/Week3/Stopwatch-the-Game/Instructions
The last line of code is the embedding code:
![StopWatch](https://github.com/jellyfishrui/Interactive-Programming-in-Python-Rice-University/blob/master/Week3/Stopwatch-the-Game/StopWatch.gif)
I also tried to embed the PNG (also saved as other formats like JPEG) and changed the extension to upper/lower case. But none of them can help me load the image. I also tried it on different browsers but they just all turned the same.
I tried the absolute/relative path and neither worked.
That file has no file extension but you're trying to use Markdown for the image. Try renaming it to Instructions.md.
Also, make sure the casing of the file matches the file you've uploaded. Guessing what case to use isn't likely to work.

Swift PDFView and URLs that end in "/pdf" instead of ".pdf"

I have code that loads a pdf file into the PDFView that Apple provides in Swift. It works great, but the problem comes when trying to view pdf files where the URL is not formatted correctly.
For example, if I provide a URL for the PDFView that looks like http://www.example.com/files/myfile.pdf the PDFView works just fine. However, when I provide it with a URL that looks like http://www.example.com/files/articles/article-432/pdf it no longer functions. Both URLs (in the code) point to perfectly valid pdf documents, but only the former actually loads into the PDFView.
EDIT So after setting the environment variable CG_PDF_VERBOSE in Xcode, the console returned failed to find PDF header: '%PDF' not found. Not really sure what this means, though I suspect it probably means that there is some sort of redirect to the actual file, so I can't get the file directly.
Sorry that I can't share the actual URLs, but its just because they are company specific and I'm not allowed to distribute them.
Thanks in advance for any help!

TinyMCE 4.3 - how to get Image Tools to save edited images as files

I don't manage to get the Image Tools plugin to actually upload the images to the server. I upload images with the jbimages plugin with no problem. But when a picture is edited with the Image Tools, although there's the uploading bar, which gets to 100%, it seems that it's only uploaded as a blob. The page calls the tinymce.activeEditor.uploadImages() function when submitting the form data, but it doesn't work.
I use the 'postacceptor.php' file from the example (defined in 'images_upload_url') and the 'images_upload_base_path' is defined as well.
The files are not uploaded to the server, and the img src remains a blob.
What could the problem be?
Thanks!
What debugging have you done in your PHP code? Is the code being triggered? Does the file appear in the posted content? You need to narrow down where in the process things are failing.
Is the issue that TinyMCE is not posting the edited image or is the issue that the image is posted and the PHP code is not properly saving the image and returning valid JSON?
How did you configure TinyMCE?
Does an edited image get posted to your server code?
What is in that form post?
If you disable the jbImages plugin does that change anything?
Without more details it will be very difficult to help you figure this out.

Downloaded ppt file seems to be corrupted

Recently I've integrated Google Drive with my iOS application. Everything works fine but .ppt files. Normally if a file is a Drive file I use downloadURL to download it. If the file belongs to Google Docs I use one of the exportLinks (exactly the same as Alain described it here).
However all .ppt files (with "mimeType": "application/vnd.google-apps.presentation") which come from Google Docs are corrupted after being downloaded (I use an export link with exportFormat=pptx). The same file downloaded via web browser works fine.
I use ASIHTTPRequest lib for downloading files (which also can be the reason of corrupted .ppt?).
Any ideas why only ppt files cause problems?
I can already tell you that the lib you're using isn't the cause:I'm not using it but I've the same problem: it seems that there the code received isn't 200 (if ($httpRequest->getResponseHttpCode() == 200)) as it shows me a specific error message I've asked to return in case of. Also, when I'm trying to download a presentation in PDF or txt, it shows the same error.
It's not really an answer but I'm trying to understand also why only presentations are causing problems.
EDIT: the code received is 302. If it can help...
EDIT 2: After trying, I noticed that the first parameter is the file id and the second the export format:
https://docs.google.com/feeds/download/presentations/Export?docId=filedid&exportFormat=pptx
But in the 302 code, I have this location:
https://docs.google.com/feeds/download/presentations/Export?exportFormat=pptx&id=fileid
Not only the two parameters aren't in the same order but the name is id and not docid
When I take this URL, put it as the export link and then try to copy the file, it's working. I get a 200 response and the inside of the file.
I hope it helps.

Unable to see any local or remote images in UIWebView when loadHTMLString is used to load page

No matter what I try, the only way I can see any images in my UIWebView, is if I load a page using loadRequest. loadHTMLString will load everything except for images.
I have tried using all the online examples of setting the base url. Nothing seems to work. I've tried setting the base url to my bundle path, no local images display. I've tried setting the base url to http://www.google.com and pasting the google home page source into a test file, load it with loadHTMLString. The page shows up with no images.
What am I doing wrong?
I'd recommend taking a peek at this...
UIWebView links
Also you may notice that between the simulator and the real device files become case sensitive on the device... I'm not sure if UIWebView makes it case insensitive but thought it might be worth mentioning incase it gives any more food for thought.
If this doesn't work perhaps you can post your code snippet as this may help.