Uploading image on iOS

Is there a way for the user of an iOS app to upload an image from the image picker or taken using the camera to something external like google drive or google sheets. Most solutions seem to require the use of an extension to encode the image into a string but this is not possible on iOS.

You will need to use an online resource (e.g. server with php) that accepts POSTed binary files. Then you can use the web component for this.

Example:

Thank you. Is it possible to set up a Google web app to do this?

As far as I am aware, it is not possible to send a binary file directly to a google apps script web app from an AI2 app ( I have been looking for years...). Your best approach would be to go out the the device native browser and do it from there.

However, there is possibly a way, though not for the faint-hearted:

Thank you. I've tried using the metricrat tutorial. I had to replace the buildrequestdata block with a Text join block as it kept coming up with an error.

Now I am able to get the access token and post the file. However now I am receiving this error: "unrecognized method. Irritants: (PatchText)". Is there a way to fix this? I get the same error if i use patchfile. A file with no data is being added to the root of the google drive currently.

Blast it, I am sorry, the PATCH method is not yet available for ioS...

You should still be able to upload a file, it just won't be named, or go to the desired folder (it will go to root), a quick google apps script could handle that...

Another alternative is to upload files to Firebase Storage ? (a different world of possibilities...)

Hmm at the moment an image with a size of 0B is being uploaded to root, it is not possible to view it as an image either. Is there a way to fix this?

Not sure what I'm doing wrong but the file uploaded to the root still has 0 bytes of data. Haven't been able to fix this issue. No modifications have been made to the uploading portion of the blocks as far as I know.

Zero bytes in the file might be a side effect of trying to read a file before the completion event has fired for the file writing operation.

Doesn't seem to be the case. Has anyone else been able to get the upload portion working on ios?

Could the path used in web.postfile need to be adjusted for IOS?

I would like to help, but do not have any ios devices here. Also do not know if the issue lies with your Google Drive API setup or with ios. Can you test with android ?

Images uploaded with an android phone work properly (still untitled but viewable and with 32KB file size)

Hmmm...

Try remove the Content-Type header:

I know this sounds odd, but somewhere else (Firebase Storage) I had an issue uploading files when specifying this header. Removing it made it work.

You may also need to remove it again, further down, in the Web2.Gottext event

Hmm doesn't seem to have worked. File uploaded is no longer a png but still has 0 b of data.
image

Don't know anything about the ios filesystem and permissions, but do your blocks have read access to the file you are uploading ?

If you have an online http server with php, you could try this, just to test the above (but it might also be possible to use a google apps script to import the file from there to google drive):

Don't know anything about the ios filesystem and permissions, but do your blocks have read access to the file you are uploading ?
Not sure how to check this but I am able to display the same paths in an image component.

Unfortunately I have no knowledge of php, but I could try

Hi, I've tried posting to the php server as shown above.
With the curl command I am able to upload an image properly, however when using the appinventor blocks on an iphone, the file uploaded has 0 bytes file size as usual.

I have not been able to try with an android phone but the blocks used are copied exactly from the site.

We need someone else with an iPhone / knowledge of ios uploading...