Creating a post with picture - reactjs

I'd like to add a feature of adding a post to my blog-app that is built using React+Redux. Basically, I want a new post to consist of author's name, his text and a picture that you can attach to the post that you're going to create. I tried using input tag with type="file", but it returns a value with encrypted adress. How do I go about getting a picture from someone's device?

Related

Does the gmail api allow editing of existing email?

I am looking for ways to slim my gmail account.
E.g. Is it possible to write a script that would do one of the following:
remove attachments from quoted text.
remove quoted text.
replace images in with links to high quality images on my G-drive.
perform an arbitrary text operation on previously received emai.
Note I don't want this to happen in the new email: I want do to this on whole folders (labels) of old mail. E.g. open the conversation thread from 2017 with the subject line, "Do you have swedish aspen" and replace each occurrence of 6 pix of SA with links?
You could use the API to get old messages, the thing is these messages if they contain attachments, or images, or whatever, they are base64encoded in your mail box.
Now what you are proposing is a kind of reconstruction of your mail box. A way to do something like that would be for example to:
Get all original messages using the Gmail API
Process them with your code
Use the insert method of Gmail API to insert the slimmed messages
Delete the originals using Gmail API
Note:
Using the insert message enables you to preserve the original dates of the messages.
References:
Users.messages: get
Users.messages: insert
Users.messages: delete

How can I get AngularJS to bind an input field to an external change?

At the moment I have an input field with the following directive:
ng-model="event.location"
I also have the input field attached to a Google Maps auto complete script. By way of example, if my user types "apa", the Google auto complete list will come up and there is the option of clicking "Apartments". However, the String "Apartments" does not bind to my variable and the "location" variable only contains the String "apa". How can I get AngularJS to bind to the full location once the user selects an option from Google Maps?
Update: It's just a one liner for Google Maps
new google.maps.places.Autocomplete(document.getElementById('location-text'));
Although I'm sure a lot more is happening behind the scenes

Manipulating Soundcloud Stream with Chrome Extension Content Script

I am writing a Chrome extension using AngularJS to add functionality to the Soundcloud stream page. I want to allow the user to create groups of artists so that they may only see a stream with tracks/shares/playlists from that group of artists.
For example, I follow 500 artists, but I want to quickly see a stream from my favorite 10 artists or from the artists I follow that are on the same label.
I am looking for advice on how I could go about making this as seamless as possible. As of right now, my approach involves getting the tracks with the Soundcloud API and using angular's ng-repeat to display the tracks in a view injected into where the stream normally goes. I realized using the Soundcloud widget was too slow and can't be customized to resemble the native stream items, so I copy/pasted the HTML that an actual stream item uses, but obviously the waveform/comment canvas and button functionality don't work.
What are my options as far as how I can approach this? Am I going to need to write my own players that look like the native Soundcloud ones? Any suggestions would be greatly appreciated.
You should use the SoundCloud API which is very well documented.
If you have already the id's of the tracks / artist, you just have to request the url
GET
http://api.soundcloud.com/tracks/ID_OF_TRACK.json?client_id=YOUR_CLIENT_ID
to get all the informations you need about this track, like the waveform_url, and for the comments you was talking about :
GET
http://api.soundcloud.com/tracks/ID_OF_TRACK/comments.json?client_id=YOUR_CLIENT_ID
To reproduce the behaviour of the comments :
POST http://api.soundcloud.com/tracks/ID_OF_TRACK/comments.json?client_id=YOUR_CLIENT_ID
(with a body param which represents the text and a timestamp in ms since the beginnin of the song, note that you must be connected)
If you don't have the id of the track, you could also use the resolve which give you all the info about a ressource if you have only the URL :
GET
http://api.soundcloud.com/resolve.json?url=https://soundcloud.com/poldoore/pete-rock-c-l-smooth-they&client_id=YOUR_CLIENT_ID

TextProperty field in NDB gets "=" appended after every line

I have very strange case which I wasn't able to debug for a day.
On my front-end I have form with textarea and submit button.
On submission, the textarea field gets saved as ndb.TextProperty()
When I submit a multiline text, the text in the database gets = or =20 characters on every line. At first I thought they get randomly inserted, but it seems every 76 characters gets one = character.
This gets really hard to debug as on my localhost instance it works perfectly fine, but on the deployed version it doesn't. They are both in sync. Also on my localhost instance the text field on the datastore entity shows correctly the newline and tab characters, but on the deployed version, the datastore field is shown as one text blob without newlines or tabs.
Anyone can guide me to the right direction ?
Oh, BlobStoreHandler you didn't mention that in your original question.
Ok there is your problem.
I don't believe you can combine the two. If you are uploading to the Blobstore you can't do other form elements, as the upload is directed to the BlobStore service.
From the docs
The user creates a blob by submitting an HTML form that includes one
or more file input fields. Your application calls create_upload_url()
to get the destination (action) of this form, passing the function a
URL path of a handler in your application. When the user submits the
form, the user's browser uploads the specified files directly to the
Blobstore. The Blobstore rewrites the user's request and stores the
uploaded file data, replacing the uploaded file data with one or more
corresponding blob keys, then passes the rewritten request to the
handler at the URL path you provided to create_upload_url(). This
handler can do additional processing based on the blob key.
So it's difficult to say exactly what is going on without seeing your code, but I seriously doubt you can do what you are trying to achieve.
I've also had the same problem,
I solved it in a way that isn't elegant, but functional:
I did a replace on the input;
here is the code
input_html_text = unicode(self.request.get('text')).replace('=\r\n', '')

Veeva Salesforce uploading presentation

maybe this is not a good quetion posted on this site, but I am trying to upload a presentation to SalesForce (https://test.salesforce.com/). I understand that at first I have to create "Key messages" which represent each slides in the presentation, then I create new CLM presentation and select presentation slides.
But then I am stucked. Is this everything to uploading the presentation or I have to migrate the presentation somewhere, upload somewhere else using FTP, etc.
I hope my question is understandable (because my English is not very good).
Thanks for help.
AFAIK, follow these steps to upload a presentation with single slide..
Create a Key message and upload the media (zip file). (Simply give key message name and upload proper well-formed zip)
Create a Presentation Slide (Just slide name)
Now, create a CLM Presentation, in which you need to browse and select the above 2 objects against their respective fields.
That's it on salesforce.
Now sync iRep app on device/iPad and it should come down in "Media".
Try this,
1.Create a new presentation
2.Go to CLM Key Messages tab and here, before creating a new key message you might need to create a new view("Create New View" link button) to group these key messages(at least that's how I do it).
Here you need to make sure that the filter method is set correctly otherwise I won't be able to see those key messages attached to this view.
So you can set sth like this(on step 2):
Field | Operator | Value
Message | contains | slide_prefix
On step 3 you need to add "Message" in "Selected fields" Tab
3.Now create a "New CLM Message" and make sure that it has "slide_prefix" on his name composition(Ex: if slide_prefix is "EXSlide" then clm message should be named like: EXSlide myslide01 or EXSlide_slide01)
4.After creating CLM key message you will be redirected to his info page where you need to upload the ".zip" file.
5.Last step is to create "New Presentation Slide"(On the bottom of the page). Here you need to input the Presentation(presentation name created on step 1), key message name(you can search for them) and a display order
Now sync the ipad and it should appear.
In addition to sTx answer, you can take a look at the "Veeva Content Creation Guidelines" (Link below). This will fit most of your developer needs.
Veeva Content Creation Guidelines
Keep in mind that often client groups have special region codes and labeling rules (see also: sTx answer to "Prefix" rules), that you have to follow, to match users and contents in a global account. If you dont, nothing will appear on the iPad. Example: yourID + Language + Country (YourID_ENG_UK.zip)
Also companys often split thier environment in two, a sandbox and a production section - Make sure you have the permission to see sandbox contents. For this purpose, activate the "Training Content" checkbox on the presentation object, to see your presentation without a migration.
All contents you create in the backend are by default visible to you on the iPad. Check the "Config" > "Media" list and look for your Zips files; if they get downloaded.

Resources