So i got successfully working Paperclip and S3 uploading in RoR 3, but it turns out that some images are prompted to download and others can be viewed in the browser. What determines this behaviour?
Part of this could be browser-specific behavior based upon the MIME file type that the server is sending your browser. .png files are most often the culprit for forced download. See this SO question about the issues between IE uploads, old MIME types, etc.
If it is inconsistent on the type of picture, there is a way you can force a file to be downloaded, but no good way to force an image to be viewed in the browser.
Edit: I know that the forced download isn't rails specific, so here is the rails-specific version
Is one of the following helps you?
Paperclip Force Download
Rails 'link_to' to Download An Image Immediately Instead of Opening it in the Browser
Both of them says to send the file to the browser as attachment.
Related
I work with alfresco 4.2
I want to get an image from alfresco through URL using uid
I can get the result through this link
http://localhost:8080/alfresco/service/api/node/content/workspace/SpacesStore/98996554-212 f-4846-876a-89b40999901a/test.jpg
my problem is to do the same thing but for a pdf file
with chrome I can not open the file
and firefox the file is opened in binary format
is there a way to open a pdf file through URL using the uid of alfresco file
I'd try using the download servlet. I believe the url you are using is not setting the mimetype headers correctly. This url should do the trick:
/alfresco/download/direct/workspace/SpacesStore/0000-0000-0000-0000/myfile.pdf
Possible reason could be mimetype of your pdf file is not correctly set. Normally browsers have addons avilable out of box which enable them to read pdf file correctly.
https://helpx.adobe.com/acrobat/using/display-pdf-in-browser.html
Those appliation are associated with perticular file types so whenever it detects that file type browser invoke that application to deal with it. So you can make sure your file's extension and mimetype are correct.
One more thing you can try is download that file and try to open it directly in browser.
Also, there are chances file may be corrupt. Are you able to see prview of pdf in alfresco?
What's the best approach to use background transfer to upload assets from gallery?
Seems like uploadTaskWithRequest:fromData: doesn't work with NSURLSession created with backgroundSessionConfiguration since it causes an exception: "Terminating app due to uncaught exception 'NSGenericException', reason: 'Upload tasks in background sessions must be from a file". Judging from the exception description background transfer shouldn't work with streamed upload tasks too.
Fair enough. uploadTaskWithRequest:fromFile: is the first thing that comes to mind when you think about uploading data that you already have on the disk. But the NSURLSession Class Reference tells us that this method works only with file urls, but when you get asset's url path it starts from "assets-library://asset/..." and providing this path doesn't work too.
So it seems that the only option left is to copy file from the assets library into a temporary directory, and provide its file url to uploadTaskWithRequest:fromFile:. But it doesn't make any sense because you already have asset file saved on your disk.
Am I missing something?
Update:
Talked with Apple engineer at Tech Talks event and he confirmed that background NSURLSession supports only file urls. So indeed, you need to copy asset library into a temporary directory, and provide its file url to uploadTaskWithRequest:fromFile: to upload it with background NSURLSession.
This behavior may change in the future though.
They also say somewhere in documentation that
Upload/download urls support only file http https schemes. Background supports only http/https.
I believe that core data and assets library urls despite being technically valid urls aren't really urls, and most likely aren't implemented by creating custom NSurlprotocol-s.
So I am inclined to believe that you should write the asset to some file and pass a URL to that file to upload task.
I'm working on a project that uploads assets as well and I have just begun converting it to nsursession using background session. So I'll try this out for myself later today to prove the theory.
For our ecommerce store, we have a backend that allows employees to upload product shots. These images are then resized to fit the design of the website.
For a while now we've been having an issue with some very weird distortion in the images. Here is a sample of the distortion:
Reuploading the image usually fixes the problem, but it's been getting worse and worse.
Today, I took at look at the original uploaded files, and I see that the distortion is there in the original file. I know that they are not being uploaded like that, so the corruption is happening during the upload. Any idea what might cause this?
The originals are produced in Photoshop on Mac, and uploaded using Firefox on a Mac.
Here is the code that uploads the file
<cffile action="UPLOAD"
filefield="form.imageFile"
destination="#UploadPath#"
nameconflict="makeunique"
accept="image/gif, image/pjpeg, image/jpeg, image/jpg, application/pdf">
So as it turns out, the issue is was specific to that computer and that browser. Seems that that specific Firefox was corrupting files randomly on upload.
Using a different browser, even on that same machine, has resolved all the issues.
I'm wokring on a small website that I wouldlike to use Less CSS with, but I am having trouble getting the .less file to become available. If I go to the path on the server that the .less file is at through ftp, the file is there in the browser and I can read it. However, tag in the html is bringing me to a 404 page. If I manually type in the location through http it does not work. Why might this be happening?
Requests for static files return 404 error (IIS 6.0)
Im not sure if i understood you correct, but: LESS is not a replacement for CSS. You must generate a CSS-file from your LESS-file to be able to serve it to the browser.
The reason why you cant view it in your browser is because the web server har no MIME-type for LESS-files, and it shouldnt have.
You can however view it through FTP cause its a "normal" text document.
Edit: You can also process the .less-file with javascript, but thats not recommended for production use...
I am using s3 to store my pdf files. But when i tries to download the files from s3 using chrome browser it doesn't do anything. It just refresh the page, no error, nothing ...
But from other browsers i can download that file.
When i checked in the console it gives 'Resource interpreted as Other but transferred with MIME type undefined.'
I got one thread from AWS https://forums.aws.amazon.com/thread.jspa?threadID=79493
But we can not tell user that go & disable this plugin & then download.
Is it a problem from AWS end?
I searched a lot but didn't get any solution.
Please help me to resolve this issue.
Thanks,
Vijay
I had this problem too. The solution it to force Chrome to download the PDF file instead of trying to open it in its reader.
In your GET request, append response-content-disposition=attachment. Refer to the S3 documentation on how to do this.
More details available here.