Save disk on google disk - google-drive-api

I need to store file from Storage::disk('local') to Storage::disk('google')
I try next code, but not working
$file = \File::get(storage_path('my/file.docx'));
\Storage::disk('google')->put($path, $file);
if I receive it from request, it work
\Storage::disk('google')->put($path, $request->file);
Can somebody help me. Thanks

This is response for my question
\Storage::disk('google')->putFile($path, new File(storage_path('file.docx')), 'file.docx');

Related

Ruby and parsing huge JSON-Lines from download

Ruby 3.1.0
I am trying to parse JSON Lines without blowing up memory. My routine prints nothing. I am wondering where I am going wrong. I open a tempfile to hold the huge file, which I am thinking is mistake #1. But I don't know how else to structure this. I then try and copy the huge file from Google to my tempfile, and then step through that one line at a time. I get nothing... I am perplexed.
Oh. I figured it out. copy_stream leaves the file at EOF. I just had to rewind it to use it.
require "tempfile"
require "open-uri"
require "json"
url = "https://storage.googleapis.com/somehugefile.jsonl"
inventory_file = Tempfile.new
inventory_file.binmode
uri = URI(url)
IO.copy_stream(uri.open, inventory_file)
f = File.foreach(inventory_file)
f.each_entry {|line| puts JSON.parse(line) }
It was simple. I did not know that copy_stream method left the file pointer at the end of the file. So I just had to do a rewind on it, and it all worked as expected.

PHP echo content of HTML page not working correctly

I am trying to use the following php code to display another html page. Sadly nothing is printed on the screen, and yes I have checked and confirmed that the link works. Any thoughts on why this could be happening would be helpful thank you.
$site = readfile("http://k9minecraft.tk/thanks.html");
echo $site;
First, make sure php is configured so that allow_url_fopen is on.
If you want to save the string to a variable, try using file_get_contents instead since it adds the file to memory. Refer file_get_contents for more detailed information on official documentation.
$site = file_get_contents("http://k9minecraft.tk/thanks.html");
echo $site;
The readfile function reads the file directly to the output buffer, so it doesn't require an echo. Refer readfile for more detailed information on official documentation.
readfile("http://k9minecraft.tk/thanks.html");
readfile is more efficient in terms of memory usage, whereas file_get_contents more useful in many situations.
<?php
//other php codes here
?>
Link Name
<?php
//continue other php codes.
?>
how about that ? Without using readfile.
readfile() actually returns just the number of characters read from the file. The content of the file is stored in buffer.
Turn output buffering OFF.
Use something like ob_end_flush
Check this too...It may help you

Can't retrieve file content via download URL

Since about an hour, I can't retrieve file content via the download URL attribute.
Each time I try to get it, API answers a 401 (unauthorized error).
Here's the code used: https://gist.github.com/arnaudbreton/5409015
Credentials are stored in GAE datastore and successfully retrieved / refresh.
The first call to file endpoint is working but not the second call to download content.
It was working this morning.
I tried different things so far:
- Revoke client secret (found as a solution in an other thread)
- Create a new client to test
- Disconnect my APP from Drive, accept it again
Nothing seems to solve my issue.
Thanks for your help.
A fix/rollback is in progress, should be back to normal soon.
You can use
resp.alternateLink;
resp.webContentLink;
i got stucked in the same issue a day back , using downloadUrl to get the content but got it with webContentLink.
var request = gapi.client.drive.files.list();
request.execute(function (resp) {
resp.alternateLink;
resp.webContentLink;
});

get real g.co url

I got on my DB, allot like this urls
http://g.co/maps/8s4th
but i need to get the real googlpe maps address so i can embed it. Someone ha any idea how to do this?
i need the real one
http://maps.google.com.mx/maps?q=monterrey&hl=es&ie=UTF8&sll=23.625269,-102.540613&sspn=26.141296,41.616211&hnear=Monterrey,+Nuevo+León&t=h&z=12
Do a GET to the g.co, look at the Location: in the 301 response you receive.
Well obviously with ajax I CAN'T, but i do it with PHP i leave the code i hope it help
<?
$url = "http://g.co/maps/rdu3e";
$response = get_headers($url, 1);
print_r($response['Location']);
?>

Pull data from FB app and store in spreadsheet

I am hoping you guys can help me out. I play a Facebook game called Dragons of Atlantis. It is a Real-Time Strategy game with a large world map. The world map is a 750x750 grid. I'd like to know the details of each coordinate of that grid, as unfortunately, there is no in-game way to view this data. Not directly, at least...
There is a JSON file which supplies the app with partial amounts of map data (data correlating to a 20x20 grid on the world map). I want to use that JSON file to store those results in a spreadsheet so I have my own record of map details I can view locally and on a whim.
Here is an example of one of the JSON files containing map data:
http://realm3.castle.wonderhill.com/api/map.json
I'll be the first to admit I hardly have any programming knowledge. I'm a SQL expert, but that knowledge seems to be getting me absolutely no where in this endeavor... :(
Any tools you guys know of which would help me achieve my ends? I don't think what I'm asking for it all that uncommon or complicated, but I cannot find a solution for the life of me.
Any help is greatly appreciated.
Hopefully the code below will get you started. Basically $jsonurl is the URL you want to call to get the map data. $json actually gets data. $json_output turns it into an array. You can then work with those arrays to insert that data into MySQL:
$jsonurl = "http://realm" . strval($realm['intRealmID']) . "." . $realm['strRealmServer'] .".castle.wonderhill.com/api/map.json?x=" . $x . "&y=" . $y . "%26timestamp=" . time() . "&_session_id=INSERTYOURSESSIONIDHERE5";
$json = file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json,true);