Potential bug in GCP regarding public access settings for a file - tensorflow

I was conversing with someone from GCS support, and they suggested that there may be a bug and that I post what's happening to the support group.
Situation
I'm trying to adapt this Tensorflow demo ...
https://www.tensorflow.org/hub/tutorials/tf2_arbitrary_image_stylization
... to something I can use with images stored on my GCP account. Substituting one of my images to run through the process.
​​I have the bucket set for allUsers to have public access, with a Role of Storage Object Viewer.
However, the demo still isn't accepting my files stored in GCS.
For example, this file is being rejected:
https://storage.googleapis.com/01_bucket-02/Green_Sea_Turtle_grazing_seagrass.jpeg
That file was downloaded from the examples in the demo, and then uploaded to my GCS and the link used in the demo. But it's not being accepted. I'm using the URL from the Copy URL link.
Re: publicly accessible data
I've been following the instructions on making data publicly accessible.
https://cloud.google.com/storage/docs/access-control/making-data-public#code-samples_1
I've performed all the above operations from the console, but the bucket still doesn't indicate public access for the bucket in question. So I'm not sure what's going on there.
Please see the attached screen of my bucket permissions settings.
So I'm hoping you can clarify if those settings look good for those files being publicly accessible.
Re: Accessing the data from the demo
I'm also following this related article on 'Accessing public data'
https://cloud.google.com/storage/docs/access-public-data#storage-download-public-object-python
There are 2 things I'm not clear on:
If I've set public access the way I have, do I still need code as in the example on the 'Access public data' article just above?
If I do need to add this to the code from the demo, can you tell me how I can find these 2 parts of the code:
a. source_blob_name = "storage-object-name"
b. destination_file_name = "local/path/to/file"
I know the path of the file above (01_bucket-02/Green_Sea_Turtle_grazing_seagrass.jpeg), but don't understand whether that's the storage-object-name or the local/path/to/file.
And if it's either one of those, then how do I find the other value?
And furthermore, to make a bucket public, why would I need to state an individual file? That's making me think that code isn't necessary.
Thank you for clarifying any issues or helping to resolve my confusion.
Doug

If I've set public access the way I have, do I still need code as in the example on the 'Access public data' article just above?
No, you don't need to. I actually did some testing and I was able to pull images in GCS, may it be set to public or not.
As what we have discussed in this thread, what's happening in your project is that the image you are trying to pull in GCS has a .jpeg extension but is not actually .jpeg. The actual image is in .jpg causing TensorFlow to not able to load it properly.
See this testing following the demo you've mentioned and the image from your bucket. Note that I used .jpg as the image's extension.
content_urls = dict(
test_public='https://storage.cloud.google.com/01_bucket-02/Green_Sea_Turtle_grazing_seagrass.jpg'
)
Also tested another image from your bucket and it was successfully loaded in TensorFlow.

Most likely the problem is your turtle ends in .jpeg and your libraries are looking for .jpg.
The Errors you're seeing would be much more helpful to figure out the problem.

Related

How can can i insert a user with profile picture using Blazor-server

I want the user to upload his picture when he registers his information.
The thing is when the user uploads his image.. should automatically create a folder with his ID to be like this wwwroot/images/UserID/fadi.jpg
Basically: you really shouldn't. The wwwroot is for static assets used by the application. You're using server-side, so in theory it might be possible but that's not what the folder is meant for. An alternative method like AWS would be preferred, but if you can't do that (either because of payment requirements or other complications) I would suggest saving the image to your database. One way to do this would be to base64 encode the image and save it that way. I'm not going to give an example of that here, there are plenty available elsewhere. One such example is this.

PHAsset - Property way to save captured PHAssets locally? (in app)

trying to understand the concept for Photos/Photos.h framework.
my goal is:
write captured video url (or asset) to app's "userDefaults".
read from "userDefaults", & fetch each saved asset data (thumbnail & url)
Since you're not providing any code (nor asking for any), I can help sort some of this out for you -- but you need to study a bit more before you can put it all together. Especially if you think you've asked a question which has one simple correct answer.
UserDefaults is not a good place to store an image. Images are big. (You should look at Apple's documentation of what UserDefaults is for/how it's intended use).
UserDefaults
There's more than one place to store images. Do you want the system to delete them if you start running out of memory? Then it belongs in cache:
let cachesPath = NSSearchPathForDirectoriesInDomains(.cachesDirectory, .userDomainMask, true).last!
Do you want to depend on it being around the next time the app is run? There is a standard place for that as well:
let userDocumentsFolder = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
Do you want iTunes to back up the images for you automatically? It expects files to be in a certain place for automatic backup. Do you have a way to keep track of where it is (the path to the file can change if the app is re-run). For that you might require persistent storage, so CoreData or Realm might be an option for you. Or you could scan your directory and create a list of files you've already saved. Then you'll need a way to select the correct one. (What did you call it? Should the user select it?)
Apple has very clearly written and useful documentation on access to the Photos library and using PHAssets. Here's just one example:
PHAsset - Photos
There are a lot of talented people on this site, and they are willing to help you, but you need to do your homework before coming here.
I recommend you read these linked documents, start writing some code, and if you run into problems please come back and ask any specific question you have about any specific problem you've encountered. Include the code which causes the problem, as well as the exact error message you are getting. We will be glad to help.

Cloud Storage Transfer "Failed"

I've tried repeatedly to use the Google Developers Console tools to Create a Transfer that works, but haven't had any luck. My source is in S3.
I tried with the "S3://" URL, but when trying to accept the transfer settings, I consistently get "source bucket doesn't exist". I test my URL by placing it in a browser, and I do get it to resolve, so I don't know what's up.
Even more puzzling is when I try using a text file of URLs. These URLs are all http:// strings, and each of them properly loads in a browser. I figured this would be even more straightforward as there are no permissions to be dealt with, really, since each file in the S3 bucket already has read permissions.
Instead, all I get in the Transfer history is "Failed", with no other information at all.
At first, I was greedy and included all my files. When I got nowhere with that, I cut it down to a single file. Still no go.
Here is the text file.
Any clues, por favor?
It looks like your text file doesn't follow the specified format. You should add the header and size/MD5 of each file as described at https://cloud.google.com/storage/transfer/#urls

LimeSurvey - Uploading a PDF

I've been using LimeSurvey to create a survey. There is a question type called File Upload that allows a user to upload a file instead of answering a question. As far as I can tell, the question type does not allow the user to upload a PDF. Is anyone aware of a workaround for this problem?
Its mostly you do not have the directories "upload" and "tmp" with write permissions. Make this necessary change and it should all be fine.
amit
If you click on the 'advanced settings' for the file upload question, there's an entry for file type that's just a comma-separated list of extensions to allow.

Joomla: Allowing a user to upload an image

Alright so I learned that to have an upload button on a page, what you do is basically call a php file (call is upload.php) that would upload a file to the server. I have no idea where I am supposed to put the php file inside the server so I can call it.
I feel stupid because I can't find any answers online. I am getting very frustrated and confused because I am told I need to create a database but I have no idea how to edit a database in Joomla. I took a class in SQL so I don't have to learn about that. I just don't know where it is. I was also told I need to make a component. But this is confusing because all I want to do is have an upload button that will upload an image to the server.
I understand your frustration. I've got the basic idea on what you are trying to do. Here are a couple of options:
You might wanna take a look at Joomla! Extensions Directory ™. You might just find there a component or a module that already does this for you.
If you want to do it on your own, than you need to create a small module or a component inside Joomla! Please refer to the Joomla! Documentation or tutorials on this topic. Please note that you won't get this working instantly, because you first need to understand how Joomla! works. So your upload.php file will go in your module / component files. I don't think you need to do any SQL.
Now the part with "allowing a user" is a bit confusing... you want to "allow" any user to upload things to your server or just let's say, registered users? Generally uploading scripts need to be very strong from the security point of view. If this is the case, that you need to do a search for Joomla! ACL
You can simply create a form and add the "media" field type.
http://docs.joomla.org/Standard_form_field_types
You can also opt for the "file" field types to allow different types of fields.
Both fields can be added using the Joomla Component Creator: http://www.notwebdesign.com/joomla-component-creator/
And you might also want to take a look at K2 which has an excellent image upload functionality that allows scaling of images into three different sizes.