I'm trying to use curl to download the wav file (or at least get a URL to point a downloader at) that is generated when you go to https://tetyys.com/SAPI4, enter text in the edit field, click "Say it" and click "Play".
If I view the page source, or right-click on the play button and click "Copy audio location", it shows that the source of the wave file is a BLOB (i.e. blob:https://tetyys.com/someHexNumber).
By viewing the script at https://tetyys.com/SAPI4/scripts/tts.js, specifically the string var "url", I determined that you can set all the values in the url like so:
https://tetyys.com/SAPI4/SAPI4?text=whatever+you+want+it+to+say&voice=Sam&pitch=100&speed=100
When I type that into Firefox, I get a dialog asking if I want to open the wav file, and when I open it, it plays as expected.
So, is there a way to do that with curl (or otherwise seamlessly from the command line) instead of Firefox?
Downloads with curl can be achieved via option -o or --output <file>, whereby -O would try to use the --remote-name. Please see man curl for more details.
You should try with a structure like
curl -o /opt/curl-7.65.3.tar.gz https://curl.haxx.se/download/curl-7.65.3.tar.gz
I also assume your specific case might need more work and a script. Because the call
curl -o test.wav https://tetyys.com/SAPI4/SAPI4 text=test&voice=Sam&pitch=100&speed=100
is generating another source. If you check the response and the header from above call you will find
Request URL:blob:https://tetyys.com/<UUID>
Request Method:GET
Status Code:206 Partial Content (from disk cache)
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
Content-Length:40166
Content-Range:bytes 0-40165/40166
Content-Type:audio/wav
so to download the audio file you would need something like
curl -o test.wav https://tetyys.com/${UUID}
maybe together with necessary cookies and headers, at least -H "Keep-Alive: 60" -H "Connection: keep-alive" to keep the session open.
Related
I have a PDF like like this:
"http://centraldata.s3.amazonaws.com/.....pdf?AWSAccessKeyId=...."
which I get from an api call. Then I pass it into an link so that users can click and download it.
<a href={pdfUrl} />
So, my question is, is there a way to let user view the PDF without downloading it? Except passing the Url into an tag, I don't know if there is any other way to use this link
When you place a page of HTML in the Public Domain (World Wide Web) you are offering a service with Dis-positions (Download to later view this page after decoding download).
If you include images, text, audio, video or even a PDF via link, then you are offering to disposition a copy of the page content (be dispossessed of all with its content) from the server to the browser.
A web site can indicate to the browser that the download need not be viewed in the browser, (many browsers do not have a PDF viewer, or the browser may be secured to a safer setting such as Download Media ONLY) the HTTP response could include the html attachment headers:
Content-Type: application/pdf
Content-Disposition: attachment; filename="file.pdf"
A web site can indicate to the browser that the download need not be viewed in the browser, but there is a possibility if the user settings allow for inline viewing, (many browsers do not have a PDF viewer or it may be secured to a safer setting such as Download ONLY) the HTTP response should include the html attachment headers:
Content-Type: application/pdf
Content-Disposition: inline; filename="file.pdf"
To avoid problems with the text parsing of the optional filename (blob: or anything will be saved to filename at the discretion of the client dispossesser) then the proffered optional filename should be "double quoted".
User security settings should ideally be set to no-popups, like blanks, open secondary windows or target tabs, since those are unfriendly, anti-social server actions.
W3 Recommendation says
< a href="download-file.pdf" download >right click here for your options including view now< /a>
If you as my client have an inline PDF viewer active, here is an iframe should you wish to use it. (Your servant)
The next two related questions are
How can I stop that content I duplicated, from being duplicated as a copy by the client?, well clearly you cannot, since you willingly gave it away and once decrypted and decoded by the receiver it belongs to them as editable dis possessed content.
How can I mask the source URL ?, generally you can not since to decode the whole file and maintain it (if required) the sending caller ID must be maintained as an open comms channel during viewing. (Much like satellite download or Netflix recordings on demand.)
just use this
MyPDF
My google cloud storage browser is seeing the incorrect content-type on all of my static files (css, js, jpg, etc.) and this is causing a mime type error when serving these files which causes my website to not apply my css styles. Why is this happening and how can I fix this? I am linking my static files correctly and with specifying the correct content-type, but this error is still happening.
<link rel="stylesheet" type="text/css" media="screen,print" href="index_files/index.css" />
<script type="text/javascript" src="index_files/index.js"></script>
As you can see in the following images, google cloud storage is seeing these static files with content-type application/octet-stream when it should be seeing them as text/css and text/javascript.
UPDATE
The files are uploaded manually to the bucket.
if you want to bulk upload your local files to Cloud Storage without having issues with octet-stream you can use Cloud SDK to upload it using gsutil command:
gsutil -m cp -r dir_of_folder_to_upload gs://bucket_name/folder
You will have to manually edit the content type in the console. The instructions are in the documentation:
Open the Cloud Storage browser in the Google Cloud Console.
In the list of buckets, click on the name of the bucket that contains the desired object, and navigate to the object.
Certain pieces of object metadata, such as the object's size and storage class, are displayed along with the object's name.
Click the more actions menu () associated with the object.
Click Edit metadata. The overlay window that appears shows the current values for the object's editable metadata.
You can also bulk update your response headers (Google cloud calls it meta data) like this:
Set header content types for CSS
gsutil -m setmeta -h "Content-Type:text/css" gs://your-bucket-name/any-folder/*.css
You can also bulk set multiple headers with one command as well:
Set multiple header content types for HTML example:
gsutil -m setmeta -h "Content-Type:text/html;charset=UTF-8" -h "Cache-Control:public, max-age=3600" gs://your-bucket-name/any-folder/*.html
You can see a list of all the headers you can set here: https://cloud.google.com/storage/docs/gsutil/addlhelp/WorkingWithObjectMetadata
the url link : https://live.eservice-hk.net/viutv
will return the text results (one text line) and show it on the browser.
I wanna to get those results via wget but I can't.
Then I watch the website page source and discovered that the page was generated by javascript.
How do I get the results instead of the javascript?
No! You cannot wget (or even curl) the dynamically generated javascript result from the page. You need a webdriver like Selenium for that or maybe use Chrome in Headless Mode.
But for that particular page (and more specifically for that particular text result), you can use curl to get the text-link:
curl -X POST -d '{"channelno":"099","deviceId":"0000anonymous_user","format":"HLS"}' https://api.viu.now.com/p8/1/getLiveURL | jq '.asset.hls.adaptive[0]'
Note: The POST data and link is taken from the page's source. jq is a nice, little command line utility to handle JSON data on command line.
Client (Request through XMLHttpRequest) -> Server.
Server [Builds CSV and prints it on the output stream of response] -> Client.
Now step 3 should be-> Client's browser should show a download dialogue (save, open and cancel). Since the content type is plain text from the server, and the content disposition is not set, can we create a file using javascript and prompt the user to download?
I know this question is slight stupid. But there is no other option. I have to do it this way.
Changing in the server side script will make it a one minute task. But I have to do it in the client side. The responseText property of the XMLHttpRequest object will be plain text and I have to show download prompt for the text file.
Is this possible?
Not that I'm aware of. But you could just use location.href (or a form, if POST data is needed) to request the server-side file. With the correct headers (Content-Disposition: attachment and I think there's another one) you can have the response be downloaded rather than displayed.
EDIT: Even better, use an iframe that's hidden. That way, you can still do a fancy "Loading, please wait" thing in the main page.
Theoretically it could be possible, by using Data URI's
<a download = "yourfile.csv" href="data:application/octet-stream;charset=YOURCHARSET;base64,BASE64allthedata">Generate</a>
I'm developing Facebook JavaScript apps on a daily basis, but keep stumbling into some code snippets I don't understand, on the Facebook Documentation, and other websites I visit.
I searched Google for CURL, and found some descriptions about it. I can't figure out how Facebook wants me to use it.
curl -F "title=Example Title" -F "description=Description" \
-F "start_time=1329417443" \
"https://graph.facebook.com/PAGE_ID/milestones?access_token=_"
It's nonsens for me. Can you help me understand in what context I can use it for Facebook , and maybe in general, and guide me in the right direction where to find more on the subject?
curl is a command line utility that lets you send an HTTP request. It can be very useful for developing with web service APIs. I believe it comes pre-installed with most linux distros but you would need to download and install it for Windows. (It probably comes with Cygwin but can be installed on its own as well.)
I would suggest making sure it's directory is added to your PATH environmental variables. Again, probably not a problem in linux but you will need to do this manually in windows.
curl is a command to fetch requests. The -F (--form) argument is used to specify form POST parameters.
Citation from man curl:
-F/--form <name=content>
(HTTP) This lets curl emulate a filled-in form in which a user
has pressed the submit button. This causes curl to POST data
using the Content-Type multipart/form-data according to RFC
2388. This enables uploading of binary files etc. To force the
'content' part to be a file, prefix the file name with an #
sign. To just get the content part from a file, prefix the file
name with the symbol <. The difference between # and < is then
that # makes a file get attached in the post as a file upload,
while the < makes a text field and just get the contents for
that text field from a file.
curl is a way of fetching items. The -F is one of many parameters...
http://curl.haxx.se/docs/manpage.html
Also:
Have you seen http://developers.facebook.com/docs/reference/api/batch/
and it could be useful for something like:
http://chaolam.wordpress.com/2010/06/07/implementing-facebook-real-time-updates-api-with-curl-examples/
of course FB docs use curl to show a common basic way to perform the request ... it depends on what platform language libraries are you using the actual way to perform the graph http request
...so that if you are Facebook JavaScript developer you have to use XMLHttpRequest (or i suppose facebook js lib calls)