Get defaut collection image by Flickr API - flickr

I can get collections by method flickr.collections.getTree. Each collection have large and small url image. If collection have mosaic image, then url is full url like https:\farm2.staticflickr.com\xxxx/cols/yyy_zzz_l.jpg.
Otherwise url contain some default url: \images\collection_default_l.gif.
But what's the full default url?

My bad. Solution is simple, should add only flickr.com:
https://www.flickr.com/images/collection_default_l.gif

Related

Uploading lat and long to umap/osm using python

I have a python script that enables me to get from openstreetmap the latitude and longitude, but I'm looking now how to create a custom map in OSM (or uMap) that allows me to upload a bunch of lat,lon coordenates and add a point in the map for each lat,lon pair. I know I can upload manually a csv file, but there are many points to put in the map and I can't upload a batch of 100k points in a single csv file. How can I achieve this?
EDIT: Following the answer of #Michael2, I created a new map and try to do the post request. However, I'm a little bit confused with the map id and the layer id.
If I create a new map, lets call it "mymap", then the ID would be "mymap_64813" or just "64813"? The "64813" is a number that umap gives me. And I can't figure out where to find the layer id :(
For uMap, you can emulate the POST request that umap uses to store the GEOJSON data. Create a new map and note the id of the map, the id of the primary data layer (umap supports multiple layers per map) and your session cookie.
Then do a POST request to:
https://umap.openstreetmap.de/de/map/<id of the map>/datalayer/update/<id of the layer>/
Make sure to send along the cookies for the owner and the csrf-token
The content should be a multipart form request with the following fields:
name: String of the layer name
display_on_load: true
rank: 0
geojson: A file with content type application/json and the actual point data in GEOJSON-Format.
To inspect this call, edit a sample map and have a look at the traffic between the client and the server using the web developer tools of your browser.

In Kentico 7 I need to get attachment information from the attachment URL

When Kentico documents have images embedded in them, the image is inserted into the HTML as an <img> tag. I need to determine if this image is hosted by Kentico and if so, use the Kentico API to retrieve the database information for it.
So far I have parsed the File GUID out of the URL like this:
const string attachmentPrefix = "~/getattachment/";
if (imageElement.LinkAddress.StartsWith(attachmentPrefix))
{
var start = attachmentPrefix.Length;
var end = imageElement.LinkAddress.IndexOf("/", start);
var fileGuidString = imageElement.LinkAddress.Substring(start, end - start);
var fileGuid = new Guid(fileGuidString);
var info = AttachmentHistoryInfoProvider.GetInfoByGuid("-- what goes here --", fileGuid);
}
But I have not found any useful methods in the Kentico API that will retrieve information about the attachment from the GUID. The closest I found was AttachmentHistoryInfoProvider.GetInfoByGuid() but it takes an objectType parameter that I can't find any documentation for.
Does anyone know how to get information on attachments in Kentico 7 starting from a File GUID?
You mention that you're talking about images in the media library, but are trying to use the AttachmentHistoryInfoProvider in your code sample. I think it depends on what you are referring to when you say 'documents have media library images embedded in them'; in what way are you embedding them? Perhaps using the Editable image web part for example.
If you are using files from the media library, you should try using MediaFileInfoProvider.GetMediaFileInfo(Guid, string) which takes the Guid of the file and the site code name. This will return you a MediaFileInfo class. You can find it in the CMS.DataEngine assembly in Kentico 7. For a file from a media library, I'd expect to see a URL like /SampleSite/media/cats/nohandskitten.aspx to be rendered.
If you're not using images from the media library, but are inserting directly into content, then yes - this is an attachment. Rather than using AttachmentHistoryInfoProvider, you should use AttachmentInfoProvider. Calling AttachmentInfoProvider.GetAttachmentInfo(Guid, string) with the Guid of the file and the site code name will return the AttachmentInfoObject. I believe the AttachmentHistoryInfoProvider will only return things to you if you have object versioning enabled. For a file from an attachment, I'd expect to see a URL like /getattachment/75408145-0995-45dc-943a-d27296a45327/nohandskitten.jpg.aspx.
These InfoProviders do fundamentally different things, so long as you know what type of information you're looking for, you should be able to choose the correct one
If you don't have it already, the API reference for Kentico 7 may be helpful: https://devnet.kentico.com/docs/7_0/kenticocms_api.zip

pouchdb alldocs get nosql attachment

I have a piece of angular2 + pouchdb code that queries cloudant and fetches documents with their attachments. The console log of the returned doc looks like the below
{"type":"some_doc"},"_attachments":{"logo.png":{"digest":"md5-UK7aKiZSqQ6Xljz4wmUMkw==","content_type":"image/png","data":"iVBO....CCGE
Truncated the data...
I'm now trying to display the image in a list of items with
<img [src]=doc.some.path>
The challenge I'm facing is that I can't dynamically reach the data element to fetch the blob and invoke the
var url = URL.createObjectURL(blob);
All the posts I found are either very old and about alldocs not supporting attachment get, or hardcoding blobs in sample code.
Please help.
Thanks,
Elvis.
The answer to your question is best expressed here. In summary:
call the PouchDB db.getAttachment function to return the image as a Blob object
call URL.createObjectURL(blob) to turn the blob into a URL consumable by an image tag
attach the URL to the img tag's src attribute

how to reference database item attachments in couchapp

I'm learning couchapp and it looks pretty easy to query database items.
But I have items with attachments, and I'd like to add hyperlinks to the attachments:
{{description}}
I can get id, attachment and description setup properly, but how do I get the current database name (or URL) from within a couchapp javascript function?
If you don't want to use relative urls, you can fetch the db name in following way:
var dbname = unescape(document.location.href).split('/')[2]
since your href looks like: http://host:port/dbname/doc...
This is also the code jquery.couch.app.js uses. So if you are using it, it's available for you in initialization code:
$.couch.app(function(app) { alert(app.db.name); });

Short and unique keys in CouchDB

I want to write a URL shortener as a standalone CouchApp, but I'm wondering if it is possible.
Obviously, a core requirement for a URL shortener is to have short and unique keys.
What I want is to POST a long URL to CouchDB and get a shortened URL. I thought about using an update handler, but it would have to query the DB to check if the key is unique, which seems not to be possible.
Is there a way to generate short and unique keys with CouchDB? Or do I need a thin wrapper around CouchDB?
I would go for a thin wrapper, based on documents with the following structure:
{ _id : short_url , url : long_url }
Inserting of a new long URL could be done in a single step: have the wrapper generate a new _id, attempt a PUT, and try again with a new _id until it succeeds. This will guarantee that every short URL is only used once.
I'm afraid this "generate, attempt, retry" approach is the only strategy that ensures uniqueness, and it's not available without a wrapper.
If you wish the same long URL to reuse the same short URL, you can also add a view that echo(doc.url,null) and grab the _id for your URL if it does exist. This means that, unless several clients try to add the same long URL at the exact same time, only one short URL will be used for that long URL.

Resources