Retriving the attachment's address,which is encoded in base64 from odoo 12 database(postgres) - odoo-12

I have a web app and i need to display an image whose address is stored in odoo database(postgre) and is encoded in base64.
Can anyone help me in how i can decode the data and get the link.
Below is an example.
The data is like this in the database
I want to decode the data to get the url which look like this:

The paths for partner image in v12 are:
/web/image?model=res.partner&field=image_medium&id=partner_id&unique=nonce
/web/image/res.partner/partner_id/image_name?unique=nonce
Where:
partner_id is the id of the partner in Odoo database.
nonce is optional, is used to avoid cache and can be current timestamp.
partner_name can be anything
The problem with this urls is that public or portal users can't access any partner data by default for privacy reasons except from themselves (including the image). Depending on your case, some solutions could be:
If you aren't concerned about privacy issues, install website_partner module, publish partners one by one, and the urls will return the real image.
create a module with a controller that delivers only the partner image using sudo().

Related

How to set AppClip invocation for URL with QueryParam?

I am trying to set the AppClip invocation for my App which is already released on app store.
I need an url such that it provides me a jobId e.g.: https://example.com/task?jobId=00001.
My use case is that I send the sms with the url https://example.com/task?jobId=00001 to the user, the user clicks on the url and the app gets started. Then for the other user I send the next url with corresponding jobId.
I did setup the AASA file for my domain (contains the JSON with "applinks" and "appclip" objects) which is valid, also the Domain status is valid on App Store Connect. There is a default experience set with title, subtitle, image and action. I also configured an advance experience for the url https://example.com/task.
However, my app clip doesn't get invoked if I access the url from either sms text or safari. :(
I do not have a web page for https://example.com/task therefore I haven't set up the meta data for this.
Is it possible to invoke the AppClip this way? It is really important for me that the URL is dynamic and I pass that jobId every time for each individual booking.
There s no much documentation and I already read at least twice Apple documentation about AppClip.
Because of this:
I do not have a web page for https://example.com/task therefore I haven't set up the meta data for this.
The answer to this:
Is it possible to invoke the AppClip this way?
Is no. Sorry, you need to own the domain you're working with, or at the very least have means to access its CNAME config (thus, be able to induce the owner of that domain to change the CNAME configs to what you want it to be, similar to what branch.io and AppsFlyer does with its users/clients).

How to remove query string from Firebase Storage download URL

Problem:
I need to be able to remove all link decoration from the download URL that is generated for images in Firebase Storage.
However, when all link decoration is stripped away, the resulting link currently would return a JSON document of the image's metadata.
Context:
The flow goes as follows:
An image is uploaded to Firebase from an iOS app. Once that is done the download URL is then sent in a POST request to an external server.
The server that the URL is being sent to doesn't accept link decoration when submitting image URLs.
Goal:
Alter the Firebase Storage download URL such as it is stripped of all link decoration like so:
https://firebasestorage.googleapis.com/v0/b/example.appspot.com/o/[FOLDER_NAME]%[IMAGE_NAME].jpg
Notes:
The problem is twofold really, first the link needs to be manipulated to remove all the link decoration. Then the behavior of the link needs to changed, since in order to return an image, you need ?alt=media following the file extension, in this case .jpg. Currently, without link decoration, using the link with my desired structure would return a JSON document of the metadata.
The current link structure is as follows:
https://firebasestorage.googleapis.com/v0/b/example.appspot.com/o/[FOLDER_NAME]%[IMAGE_NAME].jpg?alt=media&token=[TOKEN]
Desired link structure:
https://firebasestorage.googleapis.com/v0/b/example.appspot.com/o/[FOLDER_NAME]%[IMAGE_NAME].jpg
The token is necessary for accessing the image depending security rules in place, but can be ignored with the proper read permissions. I can adjust the rules as needed, but I still need to be able to remove the ?alt=media and still return an image.
Building up on Frank's answer, if you access to your associated Google Cloud Platform project, find the bucket in the Storage tab and make this bucket public, you will be able to get the image from here with the format you wish. That is, you will not be accessing through Firebase
https://firebasestorage.googleapis.com/v0/b/example.appspot.com/o/[FOLDER_NAME]%[IMAGE_NAME].jpg
but through Google Cloud Storage, with a link like
https://storage.googleapis.com/[bucket_name]/[path_to_image]
Once in your GCP project Console, access the Storage bucket with the same name as the one you have in your Firebase project. They are the same bucket. Then make the bucket public by following these steps. After that, you will be able to construct your links as mentioned above and they will be accessible with no token and no alt=media param. If you do not want to make the public to everyone, you will be able to play around with the permissions there as you wish.
You could split the url string into two halves by using String.componentsSeparatedByString(_ separator:)
Storage.storage().reference().child(filePath).downloadURL(completion: { (url, error) in
let urlString = url.absoluteString
let urlStringWithoutQueryString = urlString.componentsSeparatedByString("?").first!
})
Calling .downloadURL on a StorageReference will return you that URL, but this method can be used to remove the query string from any URL. String.componentsSeparatedByString(_ separator:) breaks a String into an array of Strings, splitting the string by any occurrence of a given separator, in this case ?.
NOTE this method assumes that ? occurs only once within the url string, which I believe is the case for all Firebase Storage urls.
You should treat the download URL that you get back from Firebase as an opaque string. There's no way to strip the parameters from a download URL without breaking that download URL.
If you want to allow public access to the files in your bucket with simpler URLs, consider making the object in your (or even your entire) bucket public.

URL links in email - resolve correct url?

Before i start thinking about this programatically, does anyone know if it is possible to actually extract the correct url from an email link that is basically a tracking module?
Our work email system auto blocks tracking based urls from email, so i am thinking of writing something to extract the correct url so people can copy and paste the tracking link into a program and it will provide the correct url.
Is this even possible with the way that email tracking works?
Here is an example of a url in an email that i recently received:
http://t.dripemail2.com/c/eyJhY2NvdW50X2lkIjoiNTE0MTQ4NSIsImRlbGl2ZXJ5X2lkIjoiOTI0NzI2MTU0IiwidXJsIjoiaHR0cHM6Ly93d3cuYXhzaWVkLmNvbS9nY3NlLWNvbXB1dGVyLXNjaWVuY2Uvb2NyLW5lYS1ndWlkZS8_X19zPXphb2txcDVpaWN4NGkxZndtYmNnIn0
Our system blocks these. It eventually resolves to:
https://www.axsied.com/gcse-computer-science/ocr-nea-guide/?__s=zaokqp5iicx4i1fwmbcg
(got our network admin to check it for me)
I want a system that gets the right url from the ugly mess that is blocked so we can actually view links from emails.
Thanks in advance for any help.
The data in tracking URLs are typically a unique ID pointing to some entry in a database, or are encrypted with a private key, so there's no way to obtain any meaningful information from them. (see answers to this related question: Generate unique link for each website visitor)
More naive approaches will simply encode the data, in which case you may be able to extract useful information from them. Funnily enough, your example URL is a base 64 encoded JSON object containing the link itself:
{
"account_id": "5141485",
"delivery_id": "924726154",
"url": "https://www.axsied.com/gcse-computer-science/ocr-nea-guide/?__s=zaokqp5iicx4i1fwmbcg"
}
In this case you could actually resolve the URL on your own, but this type of approach is uncommon for that very reason.

Insert an image into a BIRT report with a secured URL

I wanted to load an image in my report with an URL.
The following stackoverflow question answers that.
How to insert an image into a BIRT report with an URL properly?
However, my URL is not public and requires authentication to access. Like, adding an Authorization token in the header.
How can I intercept the request to insert Authorization token?
You could add a new "Scripted Data Source" and write your request in JavaScript with the required authorization token to load the Image data into your Data Source.
Then you add a data Set to get the data from the scripted data source. Afterwards you add the Image as "Dynamic image" and load the data from the Data Set that gets the data from your scripted data source. This is a bit complicated, but it should be possible.
Please search for tutorials for creating a scripted data source by yourself. This is a complex field but opens up a lot of possibilities.

Fetching Contact image from SugarCRM

I'm trying to integrate my rails app with SugarCRM. Is it possible to fetch the Contact picture from SugarCRM using REST API? Please let me know.
To get the profile image for a user do the following:
Call the login method through REST
Call the get_entry_list method through REST, with the following parameters:
Module: Users
Query: users.user_name = 'xxxx'
Select_fields: picture
The response contains the filename for the profile image, which is stored in /uploads.
However, it is not possible to view the image in that folder due to .htaccess restrictions for security reasons, but other options exist:
Extend the REST API with a method to serve profile images (similar to get_document_revision)
Login on the server from your rails app and get the image
Create a simple entrypoint+module in SugarCRM, which can show the picture
Remove the .htaccess restiction for images (if it doesn't create a security risk in your setup)
In such scenario, I faced a problem where the upload folder stores file with name of the record id, i.e the GUID without file extension.
So to cop up with this I did write a function to copy the file at same hierarchy but with its extension.
Example:
A png extension file at upload folder with name say, '32sdft-tg35f-Tuhis-675rtyf-77666-46dgc' will end up as, '32sdft-tg35f-Tuhis-675rtyf-77666-46dgc.png'
Now only the path will be require to render the image.
Rest all things as applicable as suggested by our friend, Kare !!