sapui5 UploadCollection - unable to set correct icon - sap-fiori

I try to use sap.m.UploadCollection to display attachments. Here is the example from Sap explored:
However, for my documents, I get always this icon:
I checked mimetype is set correctly for the item, filetype is set as well for the uploadcollection.
Do you know where is the trick?

I found the reason:
UploadCollection icon is mapped not to the mimetype specified, but to the filename property. So if the filename is returned without extension, like "Notes" instead of "Notes.txt", then no icon is displayed.
I still do not get why sap wants to parse filename to get extension from it, where mimetype property is 100% suitable for its purpose,
but this is the solution - provide fill filename.

Related

Use Applescript to pull PDF attachments out of a note

I am adding several PDF documents to a note using the scan documents feature in Notes on my iPhone. I want to pull those attachments to a folder on my mac. I have the notes on iCloud so the note attachments are available. I can drag and drop, of course, but I want to automate the process. I tried to record my activity through automater and Scropt Editor, but they didn't pick up the drag and drops. I have moved to writing my own apple script.
I tried a number of approaches to the duplicate. I am able to get the path to the destination folder and can reference the items in the folder. The usage of the duplicate verb in Notes eludes me.
tell application "Finder"
set FWsimple to front window
set FW to (POSIX path of (target of front window as alias))
end tell
tell application "Notes"
set theAttachment to attachment id "x-coredata://EDDBBF66-DC2A-4A84-8913- 4548B5AA5D6C/ICAttachment/p2176"
set allAttachments to get every attachment of note "Patients 5/17/22"
duplicate the attachment to FW
end tell
{FWsimple, FW, theAttachment, allAttachments}
Running the above with the duplicate statement commented out gives me the following, so I know I am getting the objects. The front window target will be changed later, but it works for now to get the correct folder.
{Finder window id 2573 of application "Finder",
"/Users/sholland/Desktop/Applescript of Notes/",
attachment id "x-coredata://EDDBBF66-DC2A-4A84-8913-4548B5AA5D6C/ICAttachment/p2176" of application "Notes",
{attachment id "x-coredata:...p2034" of application "Notes"}
}
When I run I get: error "Notes got an error: Can’t make "/Users/sholland/Desktop/Applescript of Notes/" into type location specifier." number -1700 from "/Users/sholland/Desktop/Applescript of Notes/" to location specifier. I've tried using FWsimple and FW as the location specifier.
Please tell me how to use duplicate to copy the PDF to a folder.

Error retrieving image from URL or bad URL with webContentLink

My application is trying to insert a bunch of images to google drive sheet using google app script.
The script method is calling from a Rails app as following:
#app_script.run_script(script_id, request)
The script method is trying to fetch the image through the id and insert it to the sheet.
var srcfile = DriveApp.getFileById(object.image_file_id);
srcfile.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
var image = SpreadsheetApp.openById(object.spreadsheet_id).getSheetByName(object.sheet_name).insertImage(Drive.Files.get(srcfile.getId()).webContentLink, object.column, object.row);
The problem is coming intermittently with the response error from google script:
Exception: Error retrieving image from URL or bad URL: https://drive.google.com/uc?id=1yZULGInEcjQ_nA4j_Nmy6F2e3JcYnLFP&export=download
Note that I can download the image successful if I just copy the link and paste it to browser.
The image file and its parent folder are public share.
It seem hard to detect the problem when it does not always happen.
For those who concern about my script, it is here
Exception: Error retrieving image from URL or bad URL
This is a common error message when the image size is too big.
See here for more information.
You need to recuce the image size - either manually or programmatically - before inserting.
UPDATE
If the suggestion above does not solve your issue, implement the following workaround:
Instead of inserting the image by its webContentLink with the method insertImage(url, column, row) , use the method insertImage(blobSource, column, row):
var image = SpreadsheetApp.SpreadsheetApp.openById(object.spreadsheet_id).getSheetByName(object.sheet_name).insertImage(DriveApp.getFileById(srcfile.getId()).getBlob(), object.column, object.row);
This should solve the issue.

Multiple input file tags with IOS 6+ on iPad/iPhone

EDIT :
I've been able to resolve this, after finding that iOS uploads every image as "image.jpg". In freeASPUpload.asp, I changed the following :
For Each fileItem In UploadedFiles.Items
filePath = path & fileItem.FileName
Set streamFile = Server.CreateObject("ADODB.Stream")
streamFile.Type = adTypeBinary
streamFile.Open
StreamRequest.Position=fileItem.Start
StreamRequest.CopyTo streamFile, fileItem.Length
streamFile.SaveToFile path & FileName, adSaveCreateOverWrite
streamFile.close
Set streamFile = Nothing
fileItem.Path = filePath
Next
To :
For Each fileItem In UploadedFiles.Items
FileName = GetFileName(path, fileItem.FileName)
fileItem.FileName = FileName
filePath = path & fileItem.FileName
Set streamFile = Server.CreateObject("ADODB.Stream")
streamFile.Type = adTypeBinary
streamFile.Open
StreamRequest.Position=fileItem.Start
StreamRequest.CopyTo streamFile, fileItem.Length
streamFile.SaveToFile path & FileName, adSaveCreateOverWrite
streamFile.close
Set streamFile = Nothing
fileItem.Path = filePath
Next
This is within the save function of the script. The GetFileName function iterates over what is in the folder already, and adds a number until it is unique. It then updates the file key to its new name. I've left an "image.jpg" file in the temp folder, so that it always finds one. That works for now.
What I've found, however, is for some reason, it flips the second photo out of the five that the form allows for..
I will try to fix that / look for others with the same issue. I've always had problems with iPhones and iPads rotating pictures, and it's never consistent.
I'm trying to grab multiple files from a mobile fleet of iPads and iPhones. Currently I have 5
<input type="file" name="fileX" accept="image/*">
This works fine in a browser (using free asp upload / classic ASP). In testing, it works with IOS, but only if I send one file. If I send more then one via the form, I get the error 'file not found'. It seems like the files aren't being sent at all.
The file not found kicks back when trying to manipulate the file via FSO.
Uploads here :
Dim Upload, fileName, fileSize, ks, i, fileKey
Set Upload = New FreeASPUpload
SaveFiles = ""
uploadsDirVar = "directory"
Upload.Save(uploadsDirVar)
ks = Upload.UploadedFiles.keys
Errors out here :
Set f=fs.GetFile(uploadsDirVar & "\" & Upload.UploadedFiles(fileKey).FileName)
Any ideas on how I can get around this? Everything I've read points towards the HTML5 multiple tag on a single input. However, in my scenario, this won't work. I'm also tying descriptions for the images to the fields based on field name, restricting the upload to 5, re-sizing the images on the action page before passing it to its final destination and attaching them to an email.
Any advice welcome, and thank you for your time!
**Edit
The issue seems to be that IOS names all uploads "image", coming from either the camera or the library. Now the problem is how to rename the image before the script attempts to upload it. From what I'm understanding, it needs to happen within the asp upload component before it places the file.
See the above edit for the answer. As for the flipped images - turns out they are flipped straight from the iPad. I checked the exif data and I'm not sure how to account for this in my system. If I find the answer, I'll post here.

Jasper: error opening input stream from url

I'm designing a jasper report using iReport which takes a parameter and fetches an image from a given URL:
The parameter is a user's screen name in twitter, and the url is it's profile image.
<image>
<reportElement x="4" y="51" width="73" height="64"/>
<imageExpression><![CDATA["https://api.twitter.com/1/users/profile_image?screen_name="+$F{user_screen_name}+"&size=bigger"]]></imageExpression>
</image>
It works great when the image exists. If it doesn't the following exception is thrown:
Error filling print... net.sf.jasperreports.engine.JRException: Error opening input stream from URL :
https://api.twitter.com/1/users/profile_image?screen_name=CPTCurtisHervey&size=bigger
Setting up the file resolver... net.sf.jasperreports.engine.JRRuntimeException:
net.sf.jasperreports.engine.JRException: Error opening input stream from URL :
https://api.twitter.com/1/users/profile_image?screen_name=CPTCurtisHervey&size=bigger
at net.sf.jasperreports.repo.DefaultRepositoryService.getInputStream(DefaultRepositoryService.java:138)
at net.sf.jasperreports.repo.RepositoryUtil.findInputStream(RepositoryUtil.java:186)
at net.sf.jasperreports.repo.RepositoryUtil.getBytes(RepositoryUtil.java:202)
at net.sf.jasperreports.engine.JRImageRenderer.getInstance(JRImageRenderer.java:141)
at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:498)
at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:441)
at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:257)
at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:468)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2037)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:761)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportContent(JRVerticalFiller.java:291)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:133)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:903)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:813)
at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:58)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:417)
at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:247)
at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:878)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997) Caused by:
net.sf.jasperreports.engine.JRException: Error opening input stream from URL :
https://api.twitter.com/1/users/profile_image?screen_name=CPTCurtisHervey&size=bigger
at net.sf.jasperreports.engine.util.JRLoader.getInputStream(JRLoader.java:314)
at net.sf.jasperreports.repo.DefaultRepositoryService.getInputStream(DefaultRepositoryService.java:121)
... 19 more Caused by: java.io.FileNotFoundException:
https://api.twitter.com/1/users/profile_image?screen_name=CPTCurtisHervey&size=bigger
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1401)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at java.net.URL.openStream(URL.java:1029)
at net.sf.jasperreports.engine.util.JRLoader.getInputStream(JRLoader.java:310)... 20 more
Print not filled. Try to use an EmptyDataSource...
How can i handle this situation in the jrxml file?
I would like to simply add a fixed URL address in case it can't find one.
Anyone has any suggestions?
Thank you!
I think you need to add an additional helper class to handle this. You need a static method boolean urlExists(String url) that would allow you to put this in the imageExpression:
MyClass.urlExists($F{image_url}) ? $F{image_url} : $P{fallback_image}
It would be a simple class to write... but clearly there's additional complexity in adding in another .jar file. Without that method, I can't see any way to do the processing in the .jrxml.
in jrxml file,
to show image from url resource, use image expression URL()
like below, for example $F{ADPN_NO} is parameter from report
<imageExpression><![CDATA[new URL("http://anyserver:7001/images/"+$F{ADPN_NO}+".jpg")]]></imageExpression>
when onError occurred, it will show blank item, icon, or error that is set on jrxml.
the other way, outside of jrxml file, you can use java map object which contains img urls that is check by URL() or File() Exception ..
In my case I had a report to which I "injected" the image's url and it was causing an error with the certificate (the url I was "injecting" had the IP and it had to be a name for the certificate). After I changed the url it worked.

What's the difference between the four File Results in ASP.NET MVC

ASP.NET has four different types of file results:
FileContentResult: Sends the contents of a binary file to the response.
FilePathResult: Sends the contents of a file to the response
FileResult: Returns binary output to write to the response
FileStreamResult: Sends binary content to the response by using a Stream instance
Those descriptions are take from MSDN and with the exception of the FileStreamResult the first three sound identical. So what is the difference between them?
FileResult is an abstract base class for all the others.
FileContentResult - you use it when you have a byte array you would like to return as a file
FilePathResult - when you have a file on disk and would like to return its content (you give a path)
FileStreamResult - you have a stream open, you want to return its content as a file
However, you'll rarely have to use these classes - you can just use one of Controller.File overloads and let ASP.NET MVC do the magic for you.
Great question...and deserves more details. I find myself here as a result of an interesting situation. We were delivering some pdf attachments via the MVC3/C# environment. Our code got released and we started getting some responses from our clients that the downloads were behaving strangely when they were using Chrome and the file type was being converted over to 'pdf-, attachment.pdf-, attachment'. Yup...you got it...the whole thing. So, one could rewrite it to just be 'pdf' and the file would still save intact, but what a mess!
So, to describe the initial situation, we were setting the 'Content-Disposition' header then returning a FileContentResult...
var cd = new System.Net.Mime.ContentDisposition
{
FileName = result.Attachment.FileName,
Inline = false
};
Response.AppendHeader("Content-Disposition", cd.ToString());
return File(result.Attachment.Data, MimeExtensionHelper.GetMimeType(result.Attachment.FileName), result.Attachment.FileName);
Seemed good. Worked fine in IE. So I did some research and tried implementing FileStreamResult instead (keeping the Content-Disposition setter):
MemoryStream dataStream = new MemoryStream();
dataStream.Write(result.Attachment.Data, 0, result.Attachment.Data.Length);
dataStream.Position = 0;
return new FileStreamResult(dataStream, MimeExtensionHelper.GetMimeType(result.Attachment.FileName));
It fixed the issue in Chrome! Hmmm...but why in the heck should I have to take my perfectly good byte array and stream it and then return it via this to get the file name to work right?
Then came the Fiddler.
With FileContentResult, I got 2 Content-Dispositions in the header.
With FileStreamResult, I got 1.
FileContentResult appends a Content-Disposition header when providing the File Name and Chrome considers multiples of this header as an error.
Odd reaction...but definitely one that's good to know.

Resources