Resumable uploading in latest version of Google API PHP SDK - upload

The example code for a resumable upload (usually used for large files) in the SDK is out of date and does not work (https://github.com/google/google-api-php-client/blob/master/examples/fileupload.php).
Specifically, the $request object that is passed when getting a new Google_Http_MediaFileUpload is of the wrong class type. Google_Http_MediaFileUpload wants an Google_HTTP_Request object, but in the example code, the thing being passed is actually (in recent releases of the SDK) a Google_Service_Drive_DriveFile.
After poking around a bit, I cannot see the obvious way to do this with the current SDK, with the same economy as the example code. (I can see the long-winded way, by creating Google_HTTP_Request objects myself according to the generic API documentation).
Does anyone have an example of working code for this? (I Googled but did not find any. The changes in the SDK appear to be in the last few weeks).

I tested the latest version from Git and the example is working fine. The only "problem" is that it took a little while for the script to finish processing, even after I saw the file on Google Drive.
The $request variable is actually of the expected type Google_HTTP_Request.
$request = $service->files->insert($file);
// In the above line, $service is a `Google_Service_Drive` and
// $service->files is `Google_Service_Drive_Files_Resource`'
// which extends `Google_Service_Resource`.
// That insert() method returns the result of a call
// to Google_Service_Resource::call(), which
// returns a Google_HTTP_Request

Related

Why using List<T> as stack returns _GrowableList

I am new to Flutter and Dart. I have implemented list as stack reference for code here. I am calculating path from one node to other in graph. Problem with code is it returns _GrowableList on which is either empty or null but my GetAnswer do returns a correct list(checked while debugging). Why it automatically converts it into growable, How can I have my normal list?
Here is snippet of code where I am passing my graph start node and end node to instance of GetAnswer and storing back result in path variable.
That's the real internal type for the list you created. However, it shouldn't really look like this in the tooltip, this is how it looks for me:
If you can provide code that reproduces showing the tooltip like that, I'd love to take a look. Please open a bug in GitHub.
(It's possible you're on v2.11 of Dart Code - if so, please update to v2.12 and this should be improved)

Where is 's' object cached when using AppMeasurement in DTM

Omniture's basic page tracking function, s.t(), was not crafted for AJAX implementation. Unlike the onclick s.tl() function which has some gating instructions with s.linkTrackVars and s.linkTrackEvents, the s.t() function just perpetuates every cached property through to the next call and beyond.
I used to be able to use a ClearVars function to empty out all of the s object's attributes, but now that I am using AppMeasurement and letting DTM manage my implementation with the most updated version of that library—which I want to keep doing—I can't call the s object. I get the same "ReferenceError: s is not defined" that another person asked about here!.
I tried following Crayon Violent's instructions within that post, but I can't seem to find where DTM is stashing the cached values in between Adobe calls. This code:
window.s = new AppMeasurement();
lets me change/clear the attributes of s, but it's not the s I'm looking for. When I call the next AJAX s.t() function, all of the cached values are still there.
In my experience working with DTM and AA, there has been no end to bugs and caveats and workarounds with DTM's "native integration" of AA. This is why I have more or less decided that the best thing I can do is to either manage the lib myself or else treat AA as a 3rd party script (100% implement it through rules, just ignore that it's available as a tool).
As mentioned in my answer you linked, that line of code only works to expose the AA object in the window namespace if you are managing the library yourself. When you configure DTM to manage the library, it will instantiate AA object itself, and it will be buried within its own code (Honestly, I don't know why DTM did this, considering AA puts a number of other variables in the global namespace that DTM does nothing about).
AFAIK there is no documented way to reference it, but one thing I have found that seems to work for me - which as a disclaimer to cover my own arse I do NOT officially endorse: use at your own risk - is to use the following to get a reference of it:
var s = _satellite.getToolsByType('sc')[0].getS();
This uses getToolsByType method to get an array of the SiteCatalyst (Adobe Analytics) objects setup as tools in DTM. It does this by looping through _satellite.tools and comparing _satellite.tools[n].settings.engine to what you passed to getToolsByType.
Then I use [0] to get the first one in the array, under the assumption that there's only one configured (most people only do one). Then the getS() object pulls together the s object based on the settings in DTM. So from there, you can do things with it, including making use of s.clearVars()

Set the Visitor ID in Adobe Analytics through DTM

I'm trying to set the Visitor ID in Adobe Analytics through DTM.
Above the s_code I have:
var visitor = new Visitor("xxxx")
visitor.trackingServer = "xxx.xx.xx.omtrdc.net"
I've created a data element where the legacy code used to call the
Visitor.getInstance("xxxx");
and set the Visitor ID to %Visitor ID%
That's not working however, and my visitor ID is always just set to %Visitor ID% and obviously not reading any values. I'd really appreciate any input that someone can give me.
Thanks,
Mike
The Visitor ID pops s.visitorID and is in general related to visitor id, but is not the same as s.visitor which is what gets popped for the VisitorAPI integration. DTM does not currently have a built-in field for the s.visitor variable, so you will have to set it yourself within the config, either in the Library Management code editor (assuming you are opting to c/p the core lib and not the "Managed by Adobe" option) or else in the Custom Page Code section.
Since you are popping it in a data layer first, you can reference the data layer like this:
s.visitor = _satellite.getVar('Visitor ID');
NOTE: A separate potential issue you may have is with whether or not the Visitor object is available for your data element. Since data elements are the first thing to be evaluated by DTM, you will need to ensure that the VisitorAPI.js library is output before your top page DTM script include.
If this is a problem for you, or if you are wanting to host VisitorAPI.js within DTM, then you may need to adjust where you are popping that stuff. For example, place the VisitorAPI core code above the custom code as the first stuff within the data element, before:
var visitor = new Visitor("xxxx") visitor.trackingServer = "xxx.xx.xx.omtrdc.net
Or, don't use the data element at all. Instead, put the VisitorAPI code within the Adobe Analytics custom code or core lib section and pop all that stuff (aboove the s.visitor assignment). Or a number of other methods; point is, VisitorAPI stuff must be loaded before the data element can make use of it, same as it must be loaded before Adobe Analytics can make use of it.
So DTM is changing pretty fast and furious right now. They have a "Marketing Cloud Service ID" that works well. Before I used that, however, I did find a way to fix the code. Crayon Violent was right, as usual, that the problem was that the script wasn't available yet. I fixed this by putting the following code in between the VisitorAPI.js and the AppMeasurement stuff in the DTM managed library.
var aA = new AppMeasurement();
aA.visitorNamespace="companyname";
aA.visitor = Visitor.getInstance("companyname");
In addition, there were also some issues using my localhost for testing while trying to see if I had this correct or not. If you are having issues and think you have it correct, it may be worthwhile to elevate it to a different environment.

How to get native country name with Google Closure I18n?

I am trying to see if I can use Google Closure library form my webapp's internationalization and localization needs. I tried to find any tutorials on the subject, but could not find any and it seems I am stuck when trying on my own.
I am interested in getting the native name of a country.
I am not sure how I should use the the goog.locale component, though. It seems that for example, goog.locale.getNativeCountryName('EE') always returns 'EE', instead of 'Eesti' as I would expect it to.
goog.require('goog.locale');
...
console.log( goog.locale.getNativeCountryName('EE') ) // Outputs: 'EE'
Maybe I am missing some dependencies?
EDIT: After fiddling around a little bit I discovered that if I use et_EE instead of EE, I get the expected 'Eesti'. However, that just seems plain wrong. et_EE is a locale code, not a country code, and the function clearly expects a country code... Maybe I am still doing something wrong?
getNativeCountryName() receives a language code (in this case et) and not a country code (EE). See the API docs:
Returns the country name of the provided language code in its native
language.
Therefore:
goog.require('goog.locale');
...
console.log( goog.locale.getNativeCountryName('et') ) // Should return 'Eesti'

Adobe PDF SDK - PDDocColorConvertEmbedOutputIntent and PDFA

I am using the Datalogics library 9.1 and I am trying to embed an OutputIntent in a PDF I am creating so that it will be compliant with PDFA-1B.
I'm using PdDocColorConvertEmbedOutputIntent to do so and the function call is succeeding. The intent is getting in there, I can see it in Adobe Preflight. But certain PDFA verifiers still do not like what I'm creating.
I think it may be because the PDFA/s I create with this method have an outputIntent with a subtype of "GTS_PDFX" (as shown in Preflight). I believe it needs to be "GTS_PDFA". I see nowhere to specify the subtype of the output intent in the PdDocColorConvertEmbedOutputIntent parameters. This meethod seems to automatically choose the "GTS_PDFX" subtype and not allow me to choose anything else.
Basically, I'm just reading an ICC profile into pBuffer from a file, creating the profile and embedding it as below.
AC_Profile profile = NULL;
ACMakeBufferProfile(&profile,pBuffer,nSize);
PDDocColorConvertEmbedOutputIntent(m_pDoc,profile);
Am I missing something?
The 9.1 API and early versions of the 10 API have no parameter to supply to PdDocColorConvertEmbedOutputIntent () to specify the subtype. At the time of creation there was only one subtype "GTS_PDFX" and was hard coded into the API.
Manipulation at the COS layer will be necessary to affect a change to the subtype.

Resources