I need your help. Does anyone know how to clear uploaded files from data/document_library folder. For example I develop foto upload portlet. And when user upload new foto, the previous should be deleted.
Here is example of abs example image url.
http://localhost:8080/image/journal/article?img_id=30634
How I can programatically remove files mapped with such urls?
UPDATE
After analyzing liferay database tables (Image and etc.) I have come to desicion:
if (StringUtils.isNotEmpty(portraitUrl)) {
Pattern pattern = Pattern.compile("([0-9]+)$");
Matcher matcher = pattern.matcher(portraitUrl);
if (matcher.find()) {
ImageLocalServiceUtil.deleteImage(Long.valueOf(matcher.group(0)));
}
}
Regex search for image id in portrait Url http://localhost:8080/image/journal/article?img_id=30634
Related
I am trying to form SharePoint file's thumbnail URL (in Office 365) as mentioned in https://www.techmikael.com/2020/01/retrieving-thumbnailspreviews-for.html. This uses SharPoint site ID, List ID and file item's Unique ID to generate thumbnail URL.
/_api/v2.0/sites/${this.context.pageContext.site.id}/lists/${listId}/items/${itemUniqueId}/driveItem/thumbnails/0/${maxHeight}/content${noRedirect}
But I always get error message 404 Not Found. I used search API to verify that the thumbnail URL exists in "PictureThumbnailURL" field.
I also tried with _api/v2.1/... but get the same error. Just to be sure I ran the sample SPFx web part solution available here: https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/js-msgraph-thumbnail and get the same 404 Not Found error for images.
I have already been using getpreview.ashx but I don't see preview for large video files but get the preview URL in the search even for those large files.
I can't use search API since search result may not be immediately available to get and save the thumbnail URL.
Is there any other way to get the picture thumbnail URL using REST API in SPFx?
I found a way to generate the thumbnail URL using drive API. There are properties on File object VroomDriveID and VroomItemID. Using these properties we can format the link as below:
https://{tenantname}.sharepoint.com/_api/v2.1/drives/${VroomDriveID}/items/${VroomItemID}/thumbnails/0/c400x99999/content?preferNoRedirect=true
Below is sample code to get these properties from SharePoint:
let thumbnailURL = "";
let uniqueID = "{file's unique id}";
let resolution = "c400x99999";
let caml: ICamlQuery = {
ViewXml:
<View><Query><Where><Eq><FieldRef Name='UniqueId' /><Value Type='Text'>${uniqueID}</Value></Eq></Where></Query></View>
};
// get list items
const fileItems: IItems = await sp.web.lists.getByTitle("DocLibTitle").getItemsByCAMLQuery(caml, 'FieldValuesAsText, File/VroomDriveID,File/VroomItemID');
console.log("Items: ", fileItems);
let VroomDriveID = fileItems[0]["File"]["VroomDriveID"];
let VroomItemID = fileItems[0]["File"]["VroomItemID"];
thumbnailURL = "https://{tenantname}.sharepoint.com/_api/v2.1/drives/${VroomDriveID}/items/${VroomItemID}/thumbnails/0/${resolution}/content?preferNoRedirect=true";
console.log(thumbnailURL);
I hope this helps!
Is there a way to search for a particular metadata or free text search for both assets and pages in AEM (6.1)? or later?
So that the search result will have both images/ pdfs etc and also the actual pages in the sites console?
AEM 6.2 introduced omnisearch function (magnifier icon located at the top). Depending on your location, UI will add the location parameter in the Omnisearch. For instance, if you are in Assets, clicking on omnisearch icon will automatically add Location:Assets into the search box and restrict the search result. You may manually remove Location restriction to do site wide search against all content including sites, media assets, user and groups, etc.
predicatesMap.put("group.p.or", "true"); //combine this group with OR
predicatesMap.put("group.1_group.path", searchRootPagePath);
predicatesMap.put("group.1_group.type", NT_PAGE);
predicatesMap.put("group.2_group.path", PROP_SEARCH_ROOT_ASSETS);
predicatesMap.put("group.2_group.type", NT_DAM_ASSET);
PredicateGroup predicates = PredicateConverter.createPredicates(predicatesMap);
ResourceResolver resourceResolver = request.getResource().getResourceResolver();
Query query = this.queryBuilder.createQuery(predicates, resourceResolver.adaptTo(Session.class));
if (resultsSize != 0)
{
query.setHitsPerPage(resultsSize);
}
if (resultsOffset != 0)
{
query.setStart(resultsOffset);
}
SearchResult searchResult = query.getResult();
Just introduce groups and query both pages on some path (example:
"content/we-retail") and assets ("content/dam/we-retail")
I've been tasked with creating a new column in the list of files in a Liferay 6.2 document library. For each file, that column should display a link with the text "Details" and the URL for that file's metadata page. In view_entries.jsp, I'm looking to add this field to a ResultRow. All I've been able to find so far, is DLUtil's getPreviewURL, which only seems to give me the URL for downloading the file itself, rather than leading to the metadata page. The Title column uses a TextSearchEntry, which ends up displaying with the URL I want, but I can't figure out how to either get that URL from it or change the text it displays the link with.
PortletURL rowURL = liferayPortletResponse.createRenderURL();
rowURL.setParameter("struts_action", "/document_library/view_file_entry");
rowURL.setParameter("redirect", HttpUtil.removeParameter(currentURL, liferayPortletResponse.getNamespace() + "ajax"));
rowURL.setParameter("fileEntryId", String.valueOf(fileEntry.getFileEntryId()));
In this code, fileEntry is the current document. To get the URL to the preview page, it's just rowURL.toString().
I'm fairly new to Orchard and I'm wondering about the "best" way of building a basic list of documents with a download link?
Say the scenario is this, I want to make a list of newsletters, the news letter are in PDF format and the users should be able to download then straight from the list view.
An admin, should easily be able to add a new newsletter and it should turn up in the list.
My current train of thought is to, all through the dashboard,
create a content type "Newsletter" with a title field and a Media picker field, using the media picker field to upload the PDF file.
Then create a query, with the filter on Content type "Newsletter"
Create a projection pointing to the query
However, this only gives me a list of content items, showing their title as links back to the actual content item.
I've tried adding a layout to the query and set it to display properties instead of content. By doing that I can get a list where I can control the "output" a bit more. And I've gotten it to list the title and by doing a Rewrite and putting in the MediaPicker.Url, it also displays the URL in the list. This is all good but here I get stuck..
As the MediaPicker.URL outputs the url in the format like ~/media/default/xyz/filename.pdf, I cant just put it into a a href, it doesn't give a correct download link to the file.
Soo, question is, am I thinking and doing this totally the wrong way or am I missing something obvious? All ideas and suggestions and more then welcome.
Use or adapt the following template override in your theme:
#{
var url = Model.ContentField.Url;
}
#if(Model.ContentField.Url != null) {
if (url.StartsWith("~/")) {
url = Href(url);
}
<div class="media-picker-field attachment-pdf">
<span>download</span>
</div>
}
Modify the text as needed. This template was a Fields.MediaPicker-PDF.cshtml that was used for a media picker field named PDF.
How can you add images to a Google Document (not Spreadsheet or Presentation) via Google Apps Script. I don't see an addImage method. Surely the team would not have left this out.
http://code.google.com/googleapps/appsscript/class_document.html
From the docs:
function insertImage() {
// Retrieve an image from the web.
var resp = UrlFetchApp.fetch("http://www.google.com/intl/en_com/images/srpr/logo2w.png");
// Create a document.
var doc = DocumentApp.openById("");
// Append the image to the first paragraph.
doc.getChild(0).asParagraph().appendInlineImage(resp.getBlob());
}
http://code.google.com/googleapps/appsscript/class_documentapp_listitem.html#appendInlineImage
I'm not sure if you can upload an image. But you sure can insert it into a Paragraph via a url.