In our rails app we use paperclip to save files to rackspace cloudfiles. We want to allow users to VIEW the files without needing to download them and use a program on their computer. We have found https://docs.google.com/viewer which looks good for the job
We have the following method in the controller:
def view
att = Attachment.find(params[:id])
redirect_to "http://docs.google.com/viewer?url=#{CGI.escape(att.file.expiring_url((Time.now + 60.seconds)).gsub(/^http:/, "https:"))}"
end
This generates the following url:
https://drive.google.com/viewerng/viewer?url=https://snet-storage101.syd2.clouddrive.com/v1/MossoCloudFS_4a360775-1b68-41f9-884f-e62e7567af25/container//attachments/files/000/003/488/original/AK-_Time_Recording.pdf?temp_url_sig%3Dd36797290b85f2dcd752xxxxxxe6a08951ad%26temp_url_expires%3D14xxxxx7408&u=0
The google docs viewer then tells us:
Apologies, there is no preview available.
I suspect it has to do with the "temp_url_sig" and "temp_url_expires" parameters that are appended to the pdf file url.
Any ideas how we can get this to work?
Related
I want to create a REST API using flask. I also would like to document the api using swagger 2.0. This is the reason why I chose flasgger to create a webpage for the documentation. Right now the web page is rendered but the parameters for the request are not displayed, although I did add them in the yaml file.
I added the result of the webpage as image.
Part of the content of the yaml file can be seen in the other image.
In the main file I configured the Swagger object like in the image below.
I would be really thankful, if you could help find the reason why, I am not able to see those parameters.
Source code
documentation file
webpage result
you need to wrap your view with the decorator #swag_from("your_yaml_file_here")
for example:
from flasgger import swag_from
#app.route('/colors/<palette>/')
#swag_from('colors.yml')
def colors(palette):
....
If you do not want to use the decorator you can use the docstring file: shortcut.
#app.route('/colors/<palette>/')
def colors(palette):
"""
file: colors.yml
"""
...
Refer the link https://github.com/flasgger/flasgger to know more.
I am trying to change URL while uploading document to SharePoint document library using CSOM.
Description:
We have 'XYZ' document library with following folder structure:
Folder 1
SubFolder 1
- All Documents
Now I am trying to upload document at Folder 1. and after Drag and Drop document is getting uploaded to Folder 1. What I want to do here is, Whenever user try to upload document in Folder 1, it should get uploaded to SubFolder 1 . Is there any way to change URL of document in CSOM while its getting uploaded. So that it will get uploaded to 'SubFolder 1' even though user is doing DRagDrop to 'Folder 1'.
I am getting current folder URL in state.Status= Uploading event. I want to update this URL by adding 'Subfolder 1' to currentURL , so that it will upload this document direct to updated URL.
Note: If you have any other way to do it please let me know. also Cant go for Server side code. need CSOM.
Thank you in advance.
I have implemented similar requirements before and would recommend using a workflow for this. I have left out the step for getting the FormDigestValue by making a call to /_api/web/contextinfo, but that is needed in the request header.
The following URL format is used to call the API to move the document. Here is some documentation on the API.
/_api/web/getfilebyserverrelativeurl('/Folder1/file.pdf')/moveto(newurl='/Folder1/SubFolder1/file.pdf',flags=1)
I've deployed my blog to github pages. Index page works fine, but when I click on post page, it forces browser to download file instead of rendering post.
I want to use pretty urls so I've followed middleman docs.
I get this error 'Failed to load resource: frame loading interrupted'
In my config file I have:
activate :directory_indexes
set :relative_links, true
activate :blog do |blog|
blog.prefix = "blog"
blog.permalink = ":year/:month/:title"
end
It works fine locally though. Any idea?
ok so the issue was that files generated after build process were missing extension (html).
Since directory_indexes option is on, you should end up with directory/index.html, where directory's name is actually your blog post name.
To fix it, make sure you add the extension to permalink settings, just like that.
blog.permalink = "{year}/{month}/{title}.html"
In my application I am sharing a set of images from one of my dropbox folder to few people and wrapping some control over it.
Since I am using client.media('path_to_image'), I am getting the exact url and putting it in html as
<img src="the url returned">
, but with an expiry duration.
But it wont be available to other unless the image_path is available in other user's dropbox.
Though the client.share('path_to_image') gives a public url whose expiry date is set too ahead but, the url it returns is shortend one. So I wount be able to use that url in html img tags as src.
So the only way I could short out is to invite the users to my folder so that the image path available in there dropbox client too.
Is there a way to invite users to my dropbox folder, using dropbox python sdk or api.
Any help would be really appreciated.
Thanks in advance.
I'm not sure I understand your problem, or you might be misreading the documentation for client.media(). The URL returned by that API can be used by any user without authentication (until it expires) so it's suitable for use in an tag as you suggest.
If the short URL from client.share(path) is a problem, you can call client.share(path, short_url=False) and get an unshortened URL. The links you get from that call don't lead directly to the image, though, but to a web page on which the image can be viewed or downloaded. You can actually create a direct-download link (unexpiring) from a share link if you replace www.dropbox.com with dl.dropboxusercontent.com in the URL.
I am using Django 1.4 on Google App Engine.
I have a model called Media, where the admins can upload files to use in their website. It has a field:
file = models.FileField(upload_to='/uploads/%Y/%m/%d')
It works perfectly with images (although the URL provided is weird), but that is not a problem.
The problem is when they try to upload a PDF (or anything else). Everything seems to work, but when you go to edit it, it doesn't contain any file - there is no "Currently" or anything else.
If I go to Google App Engine dashboard, the file is in Blob Viewer, and the record is also saved and available through the Datastore Viewer, with the correct blob key.
Why Django is not recognizing it? And how I can fix it?
djangoappengine contains a storage provider for the blobstore.
To me it doesn't seem like a full-featured solution, just something to get file uploads running.
I had to add this to get some functionality I needed (urls to the files).
It might make the admin work too:
https://github.com/dragonx/djangoappengine/commit/6a472a80c25bc077816c9104b45d5a64f3063273