Opening a blob storage document in _blank tab - pdf

I have a ViewModel returning a list of documents and their associated blob storage address. When the user clicks the link I want to be able to open the pdf document in another tab but using the code below I have been unable to do so.
<h4>#document.Name</h4>
I have also tried:
<h4>#document.Name</h4>

No need to include Url.Content for this as it is rendering the blob storage address straight from the database
<h4>#document.Name</h4>

Related

Web APIs FileReader() hide download option

I've successfully integrated the FileReader() that renders a file from a BLOB so the user can view and interact with it, however the revised criteria states that the user shouldn't be allowed to download the document now.
The requirement is that the download icon is removed from the FileReader() but I can't seem to find a way of doing this, as it's baked into the actual Web API.
I started to write my own PDF viewer using a basic Vue to PDF package and adding custom controls but this is a bit of a monster and I'd like to avoid a complete re-write to remove one action.
Is there any way of removing the download CTA before it renders the PDF?
More context..
The PDF is rendered in the DOM from a BLOB that's passed via an end point I hook into with Axios. I then readAsDataURL(blob) and finally create the FileReader() result as a URL.createObjectURL(blob) to give me the data that I render as the canvas src to enable the PDF viewer. Unfortunately this can't be a PNG as it needs multi pages. Thee issue is that it's sensitive docs that can only be viewed on the portal, so it's to prevent users from easily downloading (aware they could just print screen).

directus: regenerate thumbnails after having manually inserted into directus_files table

I manually inserted images into my collection table and into directus_files table with matching uuid and filename.
When I click on an item of my collection I can see the image however the thumbnails are broken:
I can see that if I manually upload an image through directus admin interface two thumbnails are created in the local folder with an uuid and a double underscore and a random hash I cannot figure out how is made.
Is there any way to regenerate the thumbnails?
Ok found out, you basically have to harness the REST API to regenerate the thumbnails otherwise Directus is not "smart" enough to regenerate them when you open an item from the collection or fallback to the original image.
The thumbnail also uses a strange hash in the filename derived from the creation time and user so you won't find the name explicitly in any table of the database.
The REST API has to be called as follows:
http://localhost:8055/assets/c1982e98-5b6d-4327-807a-2561002029d7?access_token=mytoken&width=60&height=60&quality=80
the access token is created from the user administration panel, the guid is the one in the database associated with the image.
Notice the width and height must be specified in the database table associated with the image otherwise the REST API will return a warning.

How to get public access to files or images from Podio API if I have image ID or File Object

I have created an app on Podio. Items are attached to that particular app. In the items there is an option to upload an image. Now I am authenticated with the App ID and App Token from Podio PHP API. I get the file object and grab the thumbnail link. The thumbnail link is working on the browser where I am already logged into to Podio. But it does not working on private window. It redirects me to login page.
So my question is how could I get public access to the thumbnail link?
Short answer: you cannot.
Long answer: when Podio hosts a file, it checks if you're authorized to view it. So if you're logged in and viewing the url through your browser, it will show, otherwise not.
You would need to copy the image to a publicly accessible location. For example, on your web server:
$file = PodioFile::get($file_id);
$raw = $file->get_raw();
file_put_contents("/var/www/html/image_path/".$file->name, $raw);
Then you could view the file:
http://my_domain.com/image_path/image_name.png
You can get a "public url" for a file stored in image field using Globiflow (it is now available with a premium plan). I guess it adds some kind of a proxy layer for private files. So you may add a special field to store this public URL, set/update this field value with Globiflow workflow and use this URL for public pages.
Have not found public documentation for this, but the value "Public URL" is currently available for image fields, I've specially checked.

Can JQuery File upload be used without AJAX?

I want to use something along the lines of JQuery file upload (i'm open minded) in a form with lots of other fields for the UI (ex. image previews, delete, file sizes .etc), but I want to submit the files along with the form as if i used a normal HTML file field.
Is this at all possible?
If you console.log() the form after submission you will get an object in return that has a bunch of information. Among that information you can find for example file information of the file you just upload.
You can check this http://jsfiddle.net/1r0Lprkj/1/ and open your console after you've submitted the form.
Then if you want to go deeper into this, then you can check out the Javascript FileReader which lets you do a bunch of cool stuff with the uploaded file. https://developer.mozilla.org/en-US/docs/Web/API/FileReader
To answer your question; Yes it is possible to achieve without AJAX.

How to let end user change background image in XPages?

Now I can import some ready made images into the image resources, present them as options to the end-user on the XPage, and then based on their selection, compute the 'style' property to update the background image. But it still doesn't let the user upload their own image as background.
Is there any way that doesn't involve image resource at all? I'm thinking of doing the normal fileupload control. Let the user upload an image as an attachment into a document and then somehow compute the style property by referencing the image in the attachment but I'm not sure how to do that or if that's doable at all.
If you upload the image to a "User Settings" document and also calculate the filename in a field on the document and display these documents in a view sorted by the UserName. Get the path to the document using the logged in Users name and
Calculate the path to the image. The path should look something like this.
database path + name/view/UNID/$File/Filename
If you use a RichText Lite field to store your image and set it to Thumbnail (with no size restrictions), then you can specify a fixed filename (on second tab of properties for field)
You can then reference that attachment with a URL like Fredrick mentions.